Android Question phone date time

jchal

Active Member
Licensed User
Longtime User
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
 

jchal

Active Member
Licensed User
Longtime User
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

jchal

Active Member
Licensed User
Longtime User
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

mangojack

Expert
Licensed User
Longtime User
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…