datetime
now()
Returns the current date/time from the system UTC clock in ISO-8601 format.
Example
{ currentZuluTime: ds.datetime.now() }
{ "currentZuluTime": "2019-08-19T18:58:38.313Z" }
daysBetween(string datetime1, string datetime2)
Returns the number of days between datetime1
and datetime2
. Dates are in "yyyy-MM-dd’T’HH:mm:ss.SSSVV" format.
Example
local date1 = "2019-09-20T18:53:41.425Z"; local date2 = "2019-09-14T18:53:41.425Z"; ds.datetime.daysBetween(date1, date2)
6
format(string datetime, string inputFormat, string outputFormat)
Reformats datetime
using inputFormat
and outputFormat
.
Example
ds.datetime.format("2019-07-04T21:00:00Z", "yyyy-MM-dd'T'HH:mm:ssVV", "d MMM uuuu")
4 Jul 2019
isLeapYear(string datetime)
Returns a boolean indicating if datetime
is a leap year. Dates are in "yyyy-MM-dd’T’HH:mm:ss.SSSVV" format.
Example
ds.datetime.isLeapYear("2019-09-14T18:53:41.425Z")
false
compare(string datetime1, string format1, string datetime2, string format2)
Returns 1
if datetime1 > datetime2
, -1
if datetime1 < datetime2
, and 0
if datetime1 == datetime2
.
Example
ds.datetime.compare("2019-07-04T21:00:00-0500", "yyyy-MM-dd'T'HH:mm:ssZ", "2019-07-04T21:00:00-0500", "yyyy-MM-dd'T'HH:mm:ssZ")
0
changeTimeZone(string datetime, string format, string timezone)
Changes the date timezone, retaining the instant. This normally results in a change to the local date-time. The response is formatted using the same format as an input.
Example
ds.datetime.changeTimeZone("2019-07-04T21:00:00-0500", "yyyy-MM-dd'T'HH:mm:ssZ", "America/Los_Angeles")
2019-07-04T19:00:00-0700
toLocalDate(string datetime, string format)
Returns only local date part of the datetime
parameter in the ISO-8601 format without the offset.
Example
ds.datetime.toLocalDate("2019-07-04T21:00:00-0500", "yyyy-MM-dd'T'HH:mm:ssZ")
2019-07-04
toLocalTime(string datetime, string format)
Returns only local time part of the datetime
parameter in the ISO-8601 format without the offset.
Example
ds.datetime.toLocalTime("2019-07-04T21:00:00-0500", "yyyy-MM-dd'T'HH:mm:ssZ")
21:00:00