DateTime

◷ Reading Time: 3 minutes

today

Returns the local date for today.

 today ()

todayUtc

Returns today’s date in Coordinated Universal Time (UTC).

 todayUtc ()

now

Returns the local date and time now.

 now ()

nowUtc

Returns local date and time now based on Coordinated Universal Time (UTC).

 nowUtc ()

date

Builds a local date and time with different components.

 date (year, month, day, hour, minute, second, millisecond)

isDate

Validates a string can be formatted as a date

 isDate (value, formatter)
  • value (mandatory): String value that presents a date
  • formatter: Valid list of date and time formatter
DateTime format specifier
Below is the list of formatter:

year: y yy yyy yyyy
month: M MM MMM MMMM
day: d dd ddd dddd
hour: h hh H HH
minute: m mm
second: s ss
AM/PM: t tt

For example: MM/dd/YYYY shows month, day and year separated with /
For more details please visit Format specifier

dateUtc

Builds a date and time with different components based on Coordinated Universal Time (UTC).

 date (year, month, day, hour, minute, second, millisecond)

dateDiff

Returns the time between two dates based on an interval.

 dateDiff (interval, date1, date2)
  • interval (string): years, months, weeks, days, hours, minutes, seconds, milliseconds, offset
  • date1 (datetime): beginning date
  • date2 (datetime): end date

dateDiff would calculate date1-date2 expression agnostically. When offset is selected for the interval, the result is an array of values for [days, hours, minutes, seconds, milliseconds] otherwise the value is a number.

Example 1:

Example 1: dateDiff ('years', date1, date2)

dateAdd

Adds a slot of time to a date based on an interval.

 dateAdd (interval, date1, date2)
  • interval (string): years, months, days, hours, minutes, seconds, milliseconds
  • date1 (datetime): beginning date
  • value (number): the value to be added to the date

Returns the new date/time.

Example 1:

Example 1: dateAdd ('months', date1, 23) 
Updated on April 19, 2020

Was this article helpful?

Related Articles