Alexander Stolte Expert Licensed User Longtime User Jan 18, 2024 #1 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.
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 M M Mahares Jan 18, 2024 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.
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.
M Mahares Expert Licensed User Longtime User Jan 18, 2024 #2 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
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.