formatDateTime($time) incorrectly showing AM/PM


1) Give a description of the problem
I am not sure how long this has been going on, but I just noticed that when retrieving AM/PM status from $time, the result is incorrect.

2) What is the expected behaviour?
The expression:
formatDateTime($time, "a")
should correctly return either AM or PM

3) What is actually happening?
It is returning the opposite.

Is this happening for anyone else?

Note, it does work correctly using $now:
formatDateTime($now, "a")


yes, mine is also backwards on formatDateTime($time, “a”)

Correct result on formatDateTime($now, “a”)


Thanks for confirming!


Mine is correct


$now works for me as well…

… but try this:
formatDateTime($time, "a")


You are correct. Just for fun, I tried 24 H…



Thanks for confirming.

It is not a huge deal for me, because I can use $now instead of $time… but I figured I should document the bug nonetheless…


Rather than opposite, I think it just does not understand the 4:11 P.M. format returned by $time

(expression) formatDateTime('4:11 P.M.', 'a') »»» (string) AM
(expression) formatDateTime('4:11 A.M.', 'a') »»» (string) AM

The periods cause the problem, AM and PM work fine. $time should have used AM and PM rather than A.M. and P.M. but there is no safe fix for this.


Thanks for the feedback!

Not a problem… We have mastered the art of workarounds, LOL


Indeed. For example, formatDateTime('penguin', 'a') gives PM too, which illustrates what is going on.

Actually, that only makes sense in the afternoon …


I have been able to fix this in the HE version of webCoRE.

I’ll post the update shortly. The ST version of webCoRE handles time in a very strange manner. This issue is in time parsing, which had to change a lot for HE anyway given the difference in how each platform supports time parsing.