Android Question [B4X] DateUtils.SetDateAndTime with pm

Alexander Stolte

Expert
Licensed User
Longtime User
I live in a country that has the 24 time format. How do people in the USA use the DateUtils.SetDateAndTime function? You can't specify whether the time I create is am or pm.
 
Solution
These two variants yield the same ticks and time and date:
B4X:
DateTime.DateFormat ="MM/dd/yyyy hh:mm:ss a"
    Log(DateUtils.SetDateAndTime(2024,1,18,13,59,0))   '1705604340000
    Log(DateTime.Date(DateUtils.SetDateAndTime(2024,1,18,13,59,0)))   '01/18/2024 01:59:00 PM
and this:
B4X:
 DateTime.DateFormat ="MM/dd/yyyy HH:mm:ss"
    Log(DateUtils.SetDateAndTime(2024,1,18,13,59,0))   '1705604340000
    Log(DateTime.Date(DateUtils.SetDateAndTime(2024,1,18,13,59,0)))    01/18/2024 13:59:00
The hour needs to be 0-23 in both cases from what I can gather.

Mahares

Expert
Licensed User
Longtime User
These two variants yield the same ticks and time and date:
B4X:
DateTime.DateFormat ="MM/dd/yyyy hh:mm:ss a"
    Log(DateUtils.SetDateAndTime(2024,1,18,13,59,0))   '1705604340000
    Log(DateTime.Date(DateUtils.SetDateAndTime(2024,1,18,13,59,0)))   '01/18/2024 01:59:00 PM
and this:
B4X:
 DateTime.DateFormat ="MM/dd/yyyy HH:mm:ss"
    Log(DateUtils.SetDateAndTime(2024,1,18,13,59,0))   '1705604340000
    Log(DateTime.Date(DateUtils.SetDateAndTime(2024,1,18,13,59,0)))    01/18/2024 13:59:00
The hour needs to be 0-23 in both cases from what I can gather.
 
Upvote 2
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…