Well, if this is correct, it seems that all KM Functions that use NOW()
are converting the results to Local Time:
DOW() -- returns day number based on local time
DOW(NOW()) -- same as just DOW()
--- Returns Formatted Date/Time for Current Local time + 1 HR ---
%ICUDateTimeFor%NOW()+ (60*60) %EEE, MMM d, yyyy h:mm%
Maybe this section in the bottom of the Wiki page explains things:
==== Mixing Functions and Tokens ====
You might expect %ICUDateTimeFor% TIME(2017, 1, 1) %EEE, MMM d, yyyy% to yield Sun, Jan 1, 2017.
However, it may yield Sat, Dec 31, 2016, depending on your local time zone.
Here is why:
* The TIME() function takes and returns the values in GMT.
* The %ICUDateTimeFor% token displays the localized time.
* Thus, for TIME(Year, Month, Day) (which is in GMT), the ICUDateTimeFor displayed date in local time will be one less for anyone with a negative time zone offset.
* It is best is to use TIME(Year, Month, Day, 12, 0, 0) which will give noon GMT time, and thus the same day in local time for pretty much everyone in the world (everyone with time zone differences strictly between -12 hours and +12 hours).
So, if you use %ICUDateTimeFor% TIME(2017, 1, 1 , 12, 0, 0) %EEE, MMM d, yyyy% you will now get the expected result of Sun, Jan 1, 2017
###Key Statement:
The %ICUDateTimeFor% token displays the localized time
However, this is contidicted in other Wiki articles:
ICU Date/Time Tokens
%ICUDateTimeFor%NOW()+20%format% - the specified unixtime date.
"unixtime" implies GMT, but I now believe that the "ICUDateTimeFor" returns date/time in Local Time.
I just ran this test:
--- USE GMTOFFSET() TO ADJUST TIME(m,d,y,h,m,s) USE ---
NO OFFSET -- TIME(2016,12,27) ---
Mon, Dec 26, 2016 6:00 PM
USING OFFSET -- ICUDateTimeFor%TIME(2016,12,27) - (GMTOFFSET())%EEE, MMM d, yyyy h:mm a%
Tue, Dec 27, 2016 12:00 AM
So, instead of being approximately correct using:
%ICUDateTimeFor% TIME(2017, 1, 1 , 12, 0, 0) %EEE, MMM d, yyyy%
it seems better to me to just subtract the GMT Offset:
%ICUDateTimeFor%TIME(2016,12,27) - (GMTOFFSET())%EEE, MMM d, yyyy h:mm a%
###So, I think I'm coming around to this tentative conclusion:
- While
NOW()
and TIME()
may return the current date/time in GMT, all of the KM Functions and Tokens that use them will automatically convert it to Local Time.
- The only time we need to adjust the time is when specifying a literal date/time using the
TIME(y,m,d,h,m,s)
syntax, and then we can just subtract GMTOFFSET()
which will convert the time to GMT, and then the Function/Token converts it back to Local time.
@peternlewis, can you please confirm or correct this?