User Tools

Site Tools


token:ICUDateTime

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
token:ICUDateTime [2018/04/18 16:37]
JMichaelTX [Using Plus 0 or 1 With Day of Week (v8+)]
token:ICUDateTime [2023/01/03 00:19] (current)
ccstone
Line 3: Line 3:
 The //​%ICUDateTime%//,​ //​%ICUDateTimePlus%//,​ //​%ICUDateTimeMinus%//​ and //​%ICUDateTimeFor%//​ tokens return the a date formatted in a specific format. ​ More details are provided in the [[:​Dates_and_Times|Dates and Times]] article. The //​%ICUDateTime%//,​ //​%ICUDateTimePlus%//,​ //​%ICUDateTimeMinus%//​ and //​%ICUDateTimeFor%//​ tokens return the a date formatted in a specific format. ​ More details are provided in the [[:​Dates_and_Times|Dates and Times]] article.
  
-===== Fields & Format Used by These Tokens =====+===== Required Parameters for ICUDateTime ​Tokens =====
  
 +The parameters are specified between `%` signs after the main ICDDateTime token.
  
-//​%ICUDateTime%**format**%// - the current ​date and time. +* %**ICUDateTime**%*[output ​date format]*% 
-* //​%ICUDateTimeFor%NOW()+20%**format**%// - the specified [[:​unixtime]] date. +  Returns ​the current ​date and time in the specified ​format
-//​%ICUDateTimePlus%3+6%Hours%**format**%//​ - the current time plus a specified number of the specified ​time units+  Example: ''​%ICUDateTime%EEE, MMM d, yyyy h:mm%''​ ⇢ //Mon, Jan 2, 2023 11:17//
-//%ICUDateTimeMinus%3+6%Hours%**format**%// - the current time minus a specified number of the specified time units.+
  
 +* %**ICUDateTimeFor**%*[unixtime]*%*[output date format]*%
 +  * Returns Date/Time specified by the [[:​unixtime]],​ in the user's local time zone.
 +* %**ICUDateTimePlus**%*[amount of time]*%*[unit of time]*%*[output date format]*%
 +  * Returns Date/Time calculated by the Current Date/Time **plus** the *[amount of time]*.
 +* %**ICUDateTimeMinus**%*[amount of time]*%*[unit of time]*%*[output date format]*%
 +  * Returns Date/Time calculated by the Current Date/Time **minus** the *[amount of time]*.
  
-===== Time Units =====+where: 
 +  * *[output date format]* must conform to the [ICU Date/Time codes](https://​www.keyboardmaestro.com/​action/​linkthru?​icudatetimereference). 
 +  * *[unixtime]* is the total number of seconds since the start of 1970, GMT (see [[:​unixtime]]). 
 +  * *[unit of time]* is a unit as described below. 
 +  * *[amount of time]* is a calculation,​ being the number of *[unit of time]* units to add or subtract. 
 + 
 + 
 +===== Unit of Time =====
  
 The available time units for //​%ICUDateTimePlus%//​ and //​%ICUDateTimeMinus%//​ are: The available time units for //​%ICUDateTimePlus%//​ and //​%ICUDateTimeMinus%//​ are:
Line 50: Line 63:
  
 Note how Plus 0 and Plus 1 are the same unless today is the same as the weekday. ​ Also note that Plus 0 and Minus 0 is not the same (except when today is the same as the weekday). Note how Plus 0 and Plus 1 are the same unless today is the same as the weekday. ​ Also note that Plus 0 and Minus 0 is not the same (except when today is the same as the weekday).
 +
 ===== Format Specification ===== ===== Format Specification =====
  
 The **format** is a specified with an [ICU Date Time Format Specifier](http://​www.stairways.com/​action/​linkthru?​icudatetimereference) which allows you to produce the date in almost any format you desire. The **format** is a specified with an [ICU Date Time Format Specifier](http://​www.stairways.com/​action/​linkthru?​icudatetimereference) which allows you to produce the date in almost any format you desire.
  
-Keep in mind that TIME is in GMT and the output of ICUDateTimeFor is in local time, so when doing this sort of thing it is best to use midday instead of midnight:+You can use the *Insert ICU Date Field* menu in the *Edit* menu to insert various ICU Date Field format tokens. The *Insert ICU Date Field by Name…* menu item may be particularly helpful to quickly insert field components. 
 + 
 +Keep in mind that [[:​unixtime]] ​is in GMT and the output of ICUDateTimeFor is in local time, so when doing this sort of thing it is best to use midday instead of midnight:
  
 ``` ```
Line 64: Line 80:
 ===== Using Variables with These Date/Time Tokens ===== ===== Using Variables with These Date/Time Tokens =====
  
-To use a Variable instead of a number ​in a token, like the ICUDateTimePlus tokenjust enter the Variable name without any additional %, as in:+You can use any [[manual:​Calculations|calculation]] ​in the _numeric_ parameters, like the *[amount of time]* and *[unit of time]* fields. 
 + 
 +The _text-only_ parameters must be plain textand be a valid choice for that parameter. 
 + 
 +**Examples**
  
 ``` ```
-%ICUDateTimePlus%3%Days%yyyyMMdd+%ICUDateTimePlus%3%Days%MM/dd/yyyy
-%ICUDateTimePlus%YourVariableName%Days%yyyyMMdd%+%ICUDateTimePlus%myAmountOfTime%Days%yyyyMMdd
 +%ICUDateTimePlus%myBaseNumber + 3%Months%yyyy-MM-dd%
 ``` ```
  
-For an example, see [Generate File Named Based on Day of Week [Example]](https://​forum.keyboardmaestro.com/​t/​dates-generate-file-named-based-on-day-of-week-example/​4562)+Also See
  
-===== See Also =====+* [[https://​forum.keyboardmaestro.com/​t/​icu-time-multiple-variables/​18181/​2?​u=jmichaeltx|Discussion of Using Variables With ICUDateTime]] 
 +* [Generate File Named Based on Day of Week [Example]](https://​forum.keyboardmaestro.com/​t/​dates-generate-file-named-based-on-day-of-week-example/​4562)
  
-----+===== Localization =====
  
-=== Actions ===+Prior to Mojave, and after Keyboard Maestro 9.0, dates should be in your chosen language. ​ Unfortunately Apple changed Mojave and later to make the system return dates only in the Keyboard Maestro localized language (ie, English), regardless of your chosen locale. ​ Keyboard Maestro 9.0 works around this by claiming to be in all locales, even though it is really only localized for English itself. 
 + 
 +===== See Also ===== 
 + 
 +==== Actions ​====
  
 * [[action:​Set Variable to Text|Set Variable to Text]] * [[action:​Set Variable to Text|Set Variable to Text]]
 * [[:​Actions|See all Actions]] * [[:​Actions|See all Actions]]
  
-=== Functions ===+==== Functions ​====
  
 * [[function:​DAY|DAY()]] * [[function:​DAY|DAY()]]
Line 95: Line 121:
 * [[:​Functions|See all Functions]] * [[:​Functions|See all Functions]]
  
-=== Tokens ===+==== Tokens ​====
  
 * [[token:​ICUDateTimeFor|%ICUDateTimeFor%]] * [[token:​ICUDateTimeFor|%ICUDateTimeFor%]]
Line 107: Line 133:
 * [[:​Tokens|See all Tokens]] * [[:​Tokens|See all Tokens]]
  
-=== Topics ===+==== Topics ​====
  
 * [[:Dates and Times|Dates and Times]] * [[:Dates and Times|Dates and Times]]
Line 113: Line 139:
 * [[:​unixtime]] in GMT * [[:​unixtime]] in GMT
  
----- +===== Forum =====
- +
-==== Forum ====+
  
 - [[https://​forum.keyboardmaestro.com/​t/​adding-minutes-to-current-time/​3002/​2|Adding minutes to current time]] - [[https://​forum.keyboardmaestro.com/​t/​adding-minutes-to-current-time/​3002/​2|Adding minutes to current time]]
token/ICUDateTime.1524083821.txt.gz · Last modified: 2018/04/18 16:37 by JMichaelTX