J jchal Active Member Licensed User Longtime User Mar 14, 2016 #1 i am tryinh to retrive the current date and time of the phone. i have declared the date and time as follows on Sub Globals Dim mydate As String Dim mytime As String (iknow that i have delaided themm wrong) in the sub Activity_Create(FirstTime As Boolean) i have decleared the following DateTime.dateformat = "dd/MMMM/yyyy" DateTime.TimeFormat= "hh:mm:ss" and the code i use is the following in oreder to retrive the current day and current time from the phone is the following mydate= DateTime.date(DateTime.now) mytime=DateTime.Time(DateTime.Now) can you tell me what i have done wrong..... i am a lerner you see
i am tryinh to retrive the current date and time of the phone. i have declared the date and time as follows on Sub Globals Dim mydate As String Dim mytime As String (iknow that i have delaided themm wrong) in the sub Activity_Create(FirstTime As Boolean) i have decleared the following DateTime.dateformat = "dd/MMMM/yyyy" DateTime.TimeFormat= "hh:mm:ss" and the code i use is the following in oreder to retrive the current day and current time from the phone is the following mydate= DateTime.date(DateTime.now) mytime=DateTime.Time(DateTime.Now) can you tell me what i have done wrong..... i am a lerner you see
DonManfred Expert Licensed User Longtime User Mar 14, 2016 #2 jchal said: can you tell me what i have done wrong Click to expand... What does Code: log(mydate) log(mytime) put into the log? Do you get any error? Upvote 0
jchal said: can you tell me what i have done wrong Click to expand... What does Code: log(mydate) log(mytime) put into the log? Do you get any error?
Erel B4X founder Staff member Licensed User Longtime User Mar 14, 2016 #3 It should be HH instead of hh. Upvote 0
J jchal Active Member Licensed User Longtime User Mar 14, 2016 #4 i did put Log(mydate)=DateTime.date(DateTime.now) Log(mytime)=DateTime.Time(DateTime.Now) but i am gettin erros in the compliler B4A version: 5.80 Parsing code. (0.02s) Compiling code. Error Error compiling program. Error description: Occurred on line: 69 Log(mydate)=DateTime.date(DateTime.now) Word: = it seems to me that something is not declaired correct. it the mysql databese i have the flds as follows date as date and time as time what i try to do is to get date and time from the phone and to store the value to the mysql database It should be HH instead of hh. is it correct like this DateTime.TimeFormat= "HH:MM:SS"?? Upvote 0
i did put Log(mydate)=DateTime.date(DateTime.now) Log(mytime)=DateTime.Time(DateTime.Now) but i am gettin erros in the compliler B4A version: 5.80 Parsing code. (0.02s) Compiling code. Error Error compiling program. Error description: Occurred on line: 69 Log(mydate)=DateTime.date(DateTime.now) Word: = it seems to me that something is not declaired correct. it the mysql databese i have the flds as follows date as date and time as time what i try to do is to get date and time from the phone and to store the value to the mysql database It should be HH instead of hh. is it correct like this DateTime.TimeFormat= "HH:MM:SS"??
J jchal Active Member Licensed User Longtime User Mar 14, 2016 #5 ok i shorted it out this is the answer #Region Project Attributes #ApplicationLabel: B4A Example #VersionCode: 1 #VersionName: 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: unspecified #CanInstallToExternalStorage: False #End Region #ApplicationLabel: datetime #VersionCode: 1 #VersionName: 1 #Region Activity Attributes #FullScreen: False #IncludeTitle: True #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim mydate As String Dim mytime As String End Sub Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Layout1") DateTime.dateformat = "dd/MMMM/yyyy" DateTime.TimeFormat= "HH:MM:SS" mydate=DateTime.date(DateTime.now) mytime=DateTime.Time(DateTime.Now) End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub Upvote 0
ok i shorted it out this is the answer #Region Project Attributes #ApplicationLabel: B4A Example #VersionCode: 1 #VersionName: 'SupportedOrientations possible values: unspecified, landscape or portrait. #SupportedOrientations: unspecified #CanInstallToExternalStorage: False #End Region #ApplicationLabel: datetime #VersionCode: 1 #VersionName: 1 #Region Activity Attributes #FullScreen: False #IncludeTitle: True #End Region Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules. End Sub Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module. Dim mydate As String Dim mytime As String End Sub Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Layout1") DateTime.dateformat = "dd/MMMM/yyyy" DateTime.TimeFormat= "HH:MM:SS" mydate=DateTime.date(DateTime.now) mytime=DateTime.Time(DateTime.Now) End Sub Sub Activity_Resume End Sub Sub Activity_Pause (UserClosed As Boolean) End Sub
mangojack Expert Licensed User Longtime User Mar 15, 2016 #6 jchal said: ok i shorted it out this is the answer Click to expand... Try to get in the habit of using code tags when posting code .. you might want to edit your previous posts. [Code] code goes here ... [/Code] Also you might want to bookmark this as it will come in handy ... http://developer.android.com/reference/java/text/SimpleDateFormat.html Edit : Just noticed , Your Time format should be ... Code: DateTime.TimeFormat= "hh:mm:ss" Last edited: Mar 15, 2016 Upvote 0
jchal said: ok i shorted it out this is the answer Click to expand... Try to get in the habit of using code tags when posting code .. you might want to edit your previous posts. [Code] code goes here ... [/Code] Also you might want to bookmark this as it will come in handy ... http://developer.android.com/reference/java/text/SimpleDateFormat.html Edit : Just noticed , Your Time format should be ... Code: DateTime.TimeFormat= "hh:mm:ss"