Replies: 4 comments 4 replies
-
|
Thanks for the feedback. |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
The standard library currently encompasses no I/O with an external environment, and that's a nice property to preserve. I'm opposed to breaking it with introduction of a date or similar function. |
Beta Was this translation helpful? Give feedback.
3 replies
-
|
Great idea 👍 this would be handy |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Challenges when implementing date-related functions
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
A
date()function accepts a date/time string and output unix timestamp, string or object.First argument accepts followings.
date('2023-01-01T00:00:00Z')date('1 days ago')date('2 hours ago')date('now')date(1672531200)date({ year:2023, month:1, date:1, hours:0, minutes:0, seconds:0, offsetMinutes:0})Second argument accepts output format and time zone as object properties.
The output format is specified by the
formatproperty.date('2023-01-01T00:00:00Z', { format: 'timestamp' })1672531200date('2023-01-01T00:00:00Z', { format: 'seconds' })date('2023-01-01T00:00:00Z', { format: 'date' })date('2023-01-01T00:00:00Z', { format: 'object' }){ year:2023, month:1, date:1, hours:0, minutes:0, seconds:0, offsetMinutes:0, timestamp:1672531200, value:"2023-01-01T00:00:00Z"}date('2023-01-01T00:00:00Z', { format: format_string })%Y-%d-%m %H:%M:%SDefault format is
'timestamp'.When specify
{ format: 'object' }, output object the first argument invalueproperty.The output time zone is specified by the
out_timezoneproperty.date('2023-01-01T00:00:00Z', { format: 'seconds', out_timezone: '09:00' })The
out_timezonemay be ignored in someformat.If
out_timezoneis not specified, return in the same time zone as first argument.The input time zone is specified by the
in_timezoneproperty.date('2023-01-01T00:00:00', { format: 'seconds', in_timezone: '09:00' })The
in_timezoneis ignored if time zone is indicated by first argument.If time zone is not indicated by first argument and
in_timezoneis not specified, use local time zone.Example
Beta Was this translation helpful? Give feedback.
All reactions