Create DateTime block
Purpose
To convert a textrepresntation af a DateTime to an actual DateTime object.
A DateTime object, can be manipulated with operations like "Add 4 hours" or "change timezone" unlike a textrepresentation. This also allows correct comparisons, when used in conjunction with the 'Conditional' block
Input
-
Execute
Executes when a truthy value is set. -
Input
A text representation of a given DateTime. Is forgotten when output has been provided. If nothing is provided, the default value isnow
. -
Input Format (Mandatory)
The expected format provided to the input. Configure by setting tokens in the same format, as expected e.g. "mai 25 1982" -> "LLLL dd yyyy". Check the characters in the table below ) -
Timezone
Converts any offset from the input to the desired timezone e.g. 'America/New_York', 'Europe/Amsterdam' or 'UTC'
Output
- Value
The DateTime object after conversion.
Example
My database holds the time and date for my booking confirmations in the 'UTC' timezone. I would like to convert it to 'America/New_York'.
graph LR A(["2023-08-15T13:35:00.000+1"]) --Execute--> D(Create DateTime) A --Input--> D B(["YYYY-MM-dd'T'HH:mm:ss.SSSZ"]) --Input Format--> D C(["America/New_York"]) --Timezone--> D D --Value--> E(y)
Caveats
- Use
'
to escape tokens. Often needed to interpret the 'T' as shown in the example. - Be aware of the difference between 'timezone' and 'time offset'.
Table of tokens
(Examples below given for 2014-08-06T13:07:04.054
considered as a local time in America/New_York).
Standalone token | Format token | Description | Example |
---|---|---|---|
S | millisecond, no padding | 54 |
|
SSS | millisecond, padded to 3 | 054 |
|
u | fractional seconds, (5 is a half second, 54 is slightly more) | 54 |
|
uu | fractional seconds, (one or two digits) | 05 |
|
uuu | fractional seconds, (only one digit) | 5 |
|
s | second, no padding | 4 |
|
ss | second, padded to 2 padding | 04 |
|
m | minute, no padding | 7 |
|
mm | minute, padded to 2 | 07 |
|
h | hour in 12-hour time, no padding | 1 |
|
hh | hour in 12-hour time, padded to 2 | 01 |
|
H | hour in 24-hour time, no padding | 13 |
|
HH | hour in 24-hour time, padded to 2 | 13 |
|
Z | narrow offset | +5 |
|
ZZ | short offset | +05:00 |
|
ZZZ | techie offset | +0500 |
|
z | IANA zone | America/New_York |
|
a | meridiem | AM |
|
d | day of the month, no padding | 6 |
|
dd | day of the month, padded to 2 | 06 |
|
E | c | day of the week, as number from 1-7 (Monday is 1, Sunday is 7) | 3 |
EEE | ccc | day of the week, as an abbreviate localized string | Wed |
EEEE | cccc | day of the week, as an unabbreviated localized string | Wednesday |
M | L | month as an unpadded number | 8 |
MM | LL | month as an padded number | 08 |
MMM | LLL | month as an abbreviated localized string | Aug |
MMMM | LLLL | month as an unabbreviated localized string | August |
y | year, 1-6 digits, very literally | 2014 |
|
yy | two-digit year, interpreted as > 1960 (also accepts 4) | 14 |
|
yyyy | four-digit year | 2014 |
|
yyyyy | four- to six-digit years | 10340 |
|
yyyyyy | six-digit years | 010340 |
|
G | abbreviated localized era | AD |
|
GG | unabbreviated localized era | Anno Domini |
|
GGGGG | one-letter localized era | A |
|
kk | ISO week year, unpadded | 17 |
|
kkkk | ISO week year, padded to 4 | 2014 |
|
W | ISO week number, unpadded | 32 |
|
WW | ISO week number, padded to 2 | 32 |
|
o | ordinal (day of year), unpadded | 218 |
|
ooo | ordinal (day of year), padded to 3 | 218 |
|
q | quarter, no padding | 3 |
|
D | localized numeric date | 9/6/2014 |
|
DD | localized date with abbreviated month | Aug 6, 2014 |
|
DDD | localized date with full month | August 6, 2014 |
|
DDDD | localized date with full month and weekday | Wednesday, August 6, 2014 |
|
t | localized time | 1:07 AM |
|
tt | localized time with seconds | 1:07:04 PM |
|
T | localized 24-hour time | 13:07 |
|
TT | localized 24-hour time with seconds | 13:07:04 |
|
TTT | localized 24-hour time with seconds and abbreviated offset | 13:07:04 EDT |
|
f | short localized date and time | 8/6/2014, 1:07 PM |
|
ff | less short localized date and time | Aug 6, 2014, 1:07 PM |
|
F | short localized date and time with seconds | 8/6/2014, 1:07:04 PM |
|
FF | less short localized date and time with seconds | Aug 6, 2014, 1:07:04 PM |
|
ISO | any ISO 8601 parsable date | 2014-08-06T13:07:04.054-04:00 |