kmDateTime
Formats now, or a moment offset from now, with a date format pattern.
Keyboard Maestro: ICUDateTimePlus, ICUDateTimeMinus, ICUDateTimeFor
Details #
kmDateTime(format, mode, amount) takes exactly three arguments and returns text.
format is a date pattern in Unicode (ICU) style, such as yyyy-MM-dd HH:mm. It is used in the Mac's time zone.
mode is "plus", "minus" or "for".
plusandminusstart from now. amount is a number of seconds, or words like2 days,1 hour 30 minutes,3 weeks. Seconds, minutes, hours, days, weeks, months and years are understood, singular or plural, and several can be combined.forformats a fixed moment; amount is a time in seconds since 1 January 1970 (what time returns).Any other mode is treated as
plus.
Parameters #
Takes 3 arguments.
{{ kmDateTime(text, b, c) }}
Examples #
kmDateTime("yyyy", "for", 1700000000)2023kmDateTime("EEEE d MMMM", "plus", "2 days")Saturday 17 JanuarykmDateTime("HH:mm", "minus", 3600)08:30Gotchas #
Amount text without a recognisable number and unit stops the step:
an amount of time looks like 90, 2 days or 1 hour 30 minutes, got "...".Months and years move by calendar, so
1 monthfrom 31 January lands on the Mac calendar's idea of the next month, not 30 days.Pattern letters are case-sensitive:
MMis month,mmminutes,yyyythe year,HHthe 24-hour clock.