| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| Dates_and_Times [2021/10/20 02:26] – [1. Get Current Date/Time] peternlewis | Dates_and_Times [2023/06/20 06:44] (current) – [Mixing Functions and Tokens] peternlewis |
|---|
| ###Format Codes | ###Format Codes |
| |
| **For the complete list** of codes, see the [ICU Date/Time codes](http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax). | **For the complete list** of codes, see the [ICU Date/Time codes](https://www.keyboardmaestro.com/action/linkthru?icudatetimereference). |
| |
| |
| * <TimeUnit> is one of the following: Seconds, Minutes, Hours, Days, Weeks, Months, Years, or a weekday, Sundays, Mondays, Tuesdays, Wednesdays, Thursdays, Fridays, Saturdays. | * <TimeUnit> is one of the following: Seconds, Minutes, Hours, Days, Weeks, Months, Years, or a weekday, Sundays, Mondays, Tuesdays, Wednesdays, Thursdays, Fridays, Saturdays. |
| * <Quantity> is the number of <TimeUnit>s | * <Quantity> is the number of <TimeUnit>s |
| * <format> is the format of text returned, using the [ICU Date/Time codes](http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax) | * <format> is the format of text returned, using the [ICU Date/Time codes](https://www.keyboardmaestro.com/action/linkthru?icudatetimereference) |
| * [[function:NOW|NOW()]] and [[function:TIME|TIME()]] functions return the current time in GMT | * [[function:NOW|NOW()]] and [[function:TIME|TIME()]] functions return the current time in GMT |
| * <+ or –\> is the operator to add (+) or subtract (–) | * <+ or –\> is the operator to add (+) or subtract (–) |
| ===== Mixing Functions and Tokens ===== | ===== Mixing Functions and Tokens ===== |
| |
| You might expect [[token:ICUDateTimeFor|%ICUDateTimeFor%]] [[function:TIME|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. | You might expect “%[[token:ICUDateTimeFor|ICUDateTimeFor]]%[[function:TIME|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: | Here is why: |
| * It is best is to use [[function:TIME|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). | * It is best is to use [[function:TIME|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 [[token:ICUDateTimeFor|%ICUDateTimeFor%]] [[function:TIME|TIME(2017, 1, 1 , 12, 0, 0)]] `%EEE, MMM d, yyyy%` you will now get the expected result of `Sun, Jan 1, 2017` | So, if you use “%[[token:ICUDateTimeFor|ICUDateTimeFor]]%[[function:TIME|TIME(2017, 1, 1 , 12, 0, 0)]]%EEE, MMM d, yyyy%” you will now get the expected result of `Sun, Jan 1, 2017` |
| |
| ===== Discussion on Keyboard Maestro Forum ===== | ===== Discussion on Keyboard Maestro Forum ===== |