Skip to main content

Date

Table of tokens#

Year, month, and day tokens#
TokenOutput
MonthM1 2 ... 11 12
MM01 01 ... 11 12
MMMJan Feb ... Nov Dec
MMMMJanuary February ... November December
Day of MonthD1 2 ... 30 31
Do1st 2nd ... 30th 31st
DD01 02 ... 30 31
Day of YearDDD1 2 ... 364 365
DDDD001 002 ... 364 365
YearYY70 71 ... 29 30
YYYY1970 1971 ... 2029 2030
Y-25
QuarterQ1 2 3 4
Unix TimestampX1360013296
Hour, minute, second, and offset tokens#
TokenOutput
AM/PMAAM PM
aam pm
HourH0 1 ... 22 23
HH00 01 ... 22 23
h1 2 ... 11 12
hh01 02 ... 11 12
k1 2 ... 23 24
kk01 02 ... 23 24
Minutem0 1 ... 58 59
mm00 01 ... 58 59
Seconds0 1 ... 58 59
ss00 01 ... 58 59
Time ZoneZ-07:00 -06:00 ... +06:00 +07:00
ZZ-0700 -0600 ... +0600 +0700
Week year, week, and weekday tokens#

For these, the lowercase tokens use the locale aware week start days, and the uppercase tokens use the ISO week date start days.

TokenOutput
Locale 4 digit week yeargggg2014
Locale 2 digit week yeargg14
Locale week of yearw ww1..53
Locale day of weeke0..6
Day name in localedd ddd ddddMo..Mon..Sunday
ISO 4 digit week yearGGGG2014
ISO 2 digit week yearGG14
ISO week of yearW WW1..53
ISO day of weekE1..7
Locale-aware formats#
TokenOutput
TimeLT8:30 PM
Time with secondsLTS8:30:25 PM
Month numeral, day of month, yearL09/04/1986
l9/4/1986
Month name, day of month, yearLLSeptember 4, 1986
llSep 4, 1986
Month name, day of month, year, timeLLLSeptember 4, 1986 8:30 PM
lllSep 4, 1986 8:30 PM
Month name, day of month, day of week, year, timeLLLLThursday, September 4, 1986 8:30 PM
llllThu, Sep 4, 1986 8:30 PM
Supported units#
  • y, year, years
  • M, month, months
  • D, date, dates
  • h, hour, hours
  • m, minute, minutes
  • s, second, seconds
  • ms, millisecond, milliseconds
  • ns, nanosecond, nanoseconds

now(format)#

Gets the current UTC date time formatted with the string supplied in the parameters.

Arguments
format (string): The parsing tokens.

Returns
(string): Returns the formatted time.

format(time, format)#

Formats the date time with the format supplied in the parameters.

Arguments
time (string): The ISO date time to format. format (string): The parsing tokens.

Returns
(string): Returns the formatted time.

parse(time, format)#

Parses the formatted date time to an ISO date time.

Arguments
time (string): The date time to parse. format (string): The parsing tokens.

Returns
(string): Returns the ISO date time.

add(time, amount, unit)#

Adds time to the ISO given date time.

Arguments
time (string): The ISO date time.
amount (string): The amount of unit to add.
unit (string): The unit.

Returns
(string): Returns the ISO date time.

substract(time, amount, unit)#

Substracts time to the ISO given date time.

Arguments
time (string): The ISO date time.
amount (string): The amount of unit to substract.
unit (string): The unit.

Returns
(string): Returns the ISO date time.


If you get stuck at a point above, please reach out to support@butternut.tech or via this form.
We're here to support you, and together we can build great things.