B4J Question Convert JS Code (UTC Time)

behnam_tr

Active Member
Licensed User
Longtime User
I have a Code

JavaScript:
var r = globalActions.getUtcTime(-2e3)
var i = r.getUTCHours() * 3600 + r.getUTCMinutes() * 60 + r.getUTCSeconds()
console.log(r)
console.log(i)
//Mon Feb 05 2024 20:12:45 GMT+0330 (Iran Standard Time)

//60165

i Want to Convert To B4j

How ??
 
Solution
B4X:
    Log(DateTime.Time(DateTime.Now))      ' your local time
   
    DateTime.SetTimeZone(0)                      ' set to utc
    Log(DateTime.time(DateTime.Now))      ' "local" time in utc-land

    DateTime.DateFormat = "h:mm a zzzz"     ' get fancy
    Log(DateTime.Date(DateTime.Now))

    DateTime.DateFormat = "kk:mm:ss zzzz"   'more fancy
    Log(DateTime.Date(DateTime.Now))

lots of variations

drgottjr

Expert
Licensed User
Longtime User
B4X:
    Log(DateTime.Time(DateTime.Now))      ' your local time
   
    DateTime.SetTimeZone(0)                      ' set to utc
    Log(DateTime.time(DateTime.Now))      ' "local" time in utc-land

    DateTime.DateFormat = "h:mm a zzzz"     ' get fancy
    Log(DateTime.Date(DateTime.Now))

    DateTime.DateFormat = "kk:mm:ss zzzz"   'more fancy
    Log(DateTime.Date(DateTime.Now))

lots of variations
 
Last edited:
Upvote 0
Solution
Top