In this Page
Dates function similarly to Javascript Date objects in which a Date represents the number of milliseconds since midnight January 1, 1970 UTC.
Timestamp formats may differ across different database or APIs. Migrating date information may have unintended results if those differences are not taken into consideration. Time zone settings between Cloudplex and Groundplex might differ since Cloudplex may be in UTC, while a Groundplex could be in a local time zone. |
Dates can be compared using the relational operators (>, >=, <, <=, ==). For example:
Date.parse("2011-10-10T14:48:00.123-08:00") > Date.parse("2011-10-10T12:48:00.123-08:00") // true // The following is true because a Date is a number of milliseconds since midnight January 1, 1970 UTC Date.parse("2011-10-10T15:48:00.123-08:00") > 1318286880123 |
The following methods from JavaScript are implemented for Date objects according to local time unless noted otherwise.
Description | Returns the current datetime as YYYY-MM-DDTHH:mm:ss.SSS UTC. The results are of the date-time data type. This is similar to the JavaScript now. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2017-02-21T21:34:22.025 UTC |
Description | Parses a string representation of a date, and returns it as YYYY-MM-DDTHH:mm:ss.SSS that matches the server's timezone. The results are of the date-time data type. This is similar to the JavaScript parse. | |
---|---|---|
Syntax |
This method has the following extensions from the standard:
| |
Example | Expression: Result: 2015-10-27T01:47:49.510 (in the server's timezone) Expression: Result: 2011-10-30T00:00:00.000 (in the server's timezone) Expression: Result: 2015-04-15T13:23:10.000 (in the server's timezone) Expression: Result: 2016-09-23T00:00:00.000 (in the server's timezone) |
Description | Returns the date/time in universal time. The results are of the date-time data type. This is similar to the JavaScript UTC. | |
---|---|---|
Syntax |
where:
| |
Example | Expression: Result: 2015-08-20T13:23:12.034 UTC |
Description | Returns the date in local time. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2011-10-31T00:00:00.000 |
Description | Returns the date in local time. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2011-10-31 |
Description | Returns the date in local time. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 23:42:00.000 |
Description | Returns the day of the month for the specified date as an integer between 1 and 31. This is similar to the JavaScript getDate | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 22 |
Description | Returns the day of the week for the specified date as an integer, where 0 represents Sunday. This is similar to the JavaScript getDay | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2014-09-22").getDay() Result: 1 (indicating Monday) |
Description | This is similar to the JavaScript getFullYear - returns the year of the specified date as an integer. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2017 |
Description | This is similar to the JavaScript getHours - returns the hour for the specified date as an integer between 0 and 23. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 21 |
Description | This is similar to the JavaScript getMilliseconds - returns the milliseconds in the specified date as an integer. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 125 |
Description | This is similar to the JavaScript getMinutes - returns the minutes in the specified date. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 34 |
Description | Returns the month in the specified date as an integer between 1 (January) and 12 (December). This is different from the JavaScript getMonth in that this returns months starting from 1 instead of 0. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 3 |
Description | Returns the month in the specified date as an integer between 0 (January) and 11 (December). Unlike getMonth, this expression is similar to the JavaScript getMonth. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2 |
Description | Returns the month according to UTC in the specified date as an integer between 0 (January) and 11 (December). This expression is similar to the JavaScript getUTCMonth. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 11, 0 |
Description | This is similar to the JavaScript getSeconds - returns the seconds in the specified date as an integer between 0 and 59. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 22 |
Description | This is similar to the JavaScript getTime - returns the numeric value corresponding to the time for the specified date according to universal time as the number of milliseconds since 1 January 1970 00:00:00 UTC (epoch time). | |
---|---|---|
Syntax |
| |
Example | Expression: Date.now().getTime() Result: 1487712862069 |
Description | Converts the specified time to its corresponding UTC time. | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCDate() Result: 4 |
Description | Retrieves the year component from the specified date, according to UTC. Values range from 1000 to 9999 | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCFullYear() Result: 2019 |
Description | Retrieves the month component from the specified time, according to UTC. Values range from 1 (January) to 12 (December). | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCMonth() Result: 3 |
Description | Returns the day of the week for the specified date, according to UTC. Values range from 0 (Sunday) to 6 (Saturday). | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCDay() Result: 1 (Monday) |
Description | Returns the hour component from the specified date, according to UTC. Values range from 0 to 23. | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCHours() Result: 17 |
Description | Returns the minute component from the specified date, according to UTC. Values range from 0 to 59. | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCMinutes() Result: 32 |
Description | Returns the second component from the specified date, according to UTC. Values range from 0 to 59. | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCSeconds() Result: 53 |
Description | Returns the millisecond component from the specified date, according to UTC. Values range from 0 to 999. | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getUTCMilliseconds() Result: 77 |
Description | Returns the time difference (in minutes) between the specified time and the UTC time. | |
---|---|---|
Syntax |
| |
Example | Expression: Date.parse("2019-03-04T17:32:53.077").getTimezoneOffset() Result: 0 |
Description | Returns a string representing the specified Date object. This is similar to the JavaScript toString. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2014-09-22T00:00:00.000Z |
Description | Returns a string with a language-sensitive representation of the date and time. You can specify the formatting conventions of a given language that should be used and customize the behavior of the function. See Database Date Types for compatible date-related formats when data comes from a database. The argument to this method is an object containing the following options that control the format of the returned string:
This is similar to the JavaScript toLocaleString. | |
---|---|---|
Syntax |
| |
Example | Expressions:
Result: |
Description | Returns a string with a language sensitive representation of the date portion of this date. See Database Date Types for compatible date-related formats when data comes from a database. The argument to this method is an object containing the following options that control the format of the returned string:
This is similar to the JavaScript toLocaleDateString. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2014-09-22 Expression: Result: 09-22-2014 Expression:
Result: |
Description | Returns a string with a language sensitive representation of the time portion of this date. See Database Date Types for compatible date-related formats when data comes from a database. The argument to this method is an object containing the following options that control the format of the returned string:
This is similar to the JavaScript toLocaleDateTimeString. | |
---|---|---|
Syntax |
| |
Example | Expression: Result: 2024-03-29T00:00:00.000 Expression:
Date.now().toLocaleDateTimeString({"locale":"ar-EG"}) Result: For the {"timeZone":"zoneValue"} option, you can use the Canonical ID value from Joda-Time. Expression:
Result: |
Description | Returns a string with a language-sensitive representation of the time portion of this date. See Database Date Types for compatible date-related formats when data comes from a database. The argument to this method is an object containing the following options that control the format of the returned string:
This is similar to the JavaScript toLocaleTimeString.
| ||||
---|---|---|---|---|---|
Syntax |
| ||||
Example | Expression: Date.parse("2014-09-22").toLocaleTimeString() Result: 00:00:00.000 Expression:
Result: |
In addition to the above methods, Date objects implement the following methods from the Joda-Time Java library. "Plus" items increase the indicated datetime element by the specified value, "minus" items subtract by the specified value, and "with" replaces the existing data with the specified value.
Description | Format the date using the given format as described in an object. | |
---|---|---|
Syntax |
| |
Example | Expression: 'JS_SomeFile' + Date.now().toLocaleDateTimeString({"format":"yyyyMMddhhmmss"}) + '.json' Result: JS_SomeFile20171106112401.json |
Description | Returns a copy of this datetime with the specified duration added. This is similar to the JavaScript plus. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plus(2) Result: 2017-11-06T21:48:11.954 UTC (last digit increased by 2) Expression: Date.now().plus(20) Result: 2017-11-06T21:48:11.972 UTC (second to last digit increased by 2) Expression: Date.now().plus(2000) Result: 2017-11-06T21:48:13.952 UTC (fourth digit from the end increased by 2) |
Description | Returns a copy of this datetime plus the specified number of days. This is similar to the JavaScript plusDays. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusDays(2) Result: 2017-11-08T21:48:11.952 UTC (day value increased by 2) |
Description | Returns a copy of this datetime plus the specified number of hours. This is similar to the JavaScript plusHours. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusHours(2) Result: 2017-11-06T23:48:11.952 UTC (hour increased by 2) |
Description | Returns a copy of this datetime plus the specified number of milliseconds. This is similar to the JavaScript plusMillis. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusMillis(2) Result: 2017-11-06T21:48:11.954 UTC (milliseconds increased by 2) |
Description | Returns a copy of this datetime plus the specified number of minutes. This is similar to the JavaScript plusMinutes. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusMinutes(2) Result: 2017-11-06T21:50:11.952 UTC (minutes increased by 2) |
Description | Returns a copy of this datetime plus the specified number of months. This is similar to the JavaScript plusMonths. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusMonths(2) Result: 2018-01-06T21:48:11.952 UTC (date increased by 2 months) |
Description | Returns a copy of this datetime plus the specified number of seconds. This is similar to the JavaScript plusSeconds. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusSeconds(2) Result: 2017-11-06T21:48:13.952 UTC (time increased by 2 seconds) |
Description | Returns a copy of this datetime plus the specified number of weeks. This is similar to the JavaScript plusWeeks. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusWeeks(2) Result: 2017-11-20T21:48:11.952 UTC (date increased by 2 weeks) |
Description | Returns a copy of this datetime plus the specified number of years. This is similar to the JavaScript plusYears. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().plusYears(2) Result: 2019-11-06T21:48:11.952 UTC (year increased by 2) |
Description | Returns a copy of this datetime with the specified duration subtracted. This is similar to the JavaScript minus. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minus(2) Result: 2017-11-06T21:48:11.950 UTC |
Description | Returns a copy of this datetime minus the specified number of days. This is similar to the JavaScript minusDays. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusDays(2) Result: 2017-11-04T21:48:11.952 UTC (day reduced by 2) |
Description | Returns a copy of this datetime minus the specified number of hours. This is similar to the JavaScript minusHours. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusHours(2) Result: 2017-11-06T19:48:11.952 UTC (hours reduced by 2) |
Description | Returns a copy of this datetime minus the specified number of milliseconds. This is similar to the JavaScript minusMillis. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusMillis(2) Result: 2017-11-06T21:48:11.950 UTC (milliseconds reduced by 2) |
Description | Returns a copy of this datetime minus the specified number of minutes. This is similar to the JavaScript minusMinutes. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusMinutes(2) Result: 2017-11-06T21:46:11.952 UTC (minutes reduced by 2) |
Description | Returns a copy of this datetime minus the specified number of months. This is similar to the JavaScript minusMonths. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusMonths(2) Result: 2017-09-06T21:48:11.952 UTC (months reduced by 2) |
Description | Returns a copy of this datetime minus the specified number of seconds. This is similar to the JavaScript minusSeconds. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusSeconds(2) Result: 2017-11-06T21:48:09.952 UTC |
Description | Returns a copy of this datetime minus the specified number of weeks. This is similar to the JavaScript minusWeeks. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusWeeks(2) Result: 2017-10-23T21:48:11.952 UTC (date decreased by 2 weeks) |
Description | Returns a copy of this datetime minus the specified number of years. This is similar to the JavaScript minusYears. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().minusYears(2) Result: 2015-11-06T21:48:11.952 UTC (year reduced by 2) |
Description | Returns a copy of this datetime with the day of the month field specified. This is similar to the JavaScript withDayOfMonth. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withDayOfMonth(4) Result: 2017-11-04T21:48:11.952 UTC (day changed to 4) |
Description | Returns a copy of this datetime with the day of the year field specified This is similar to the JavaScript withDayOfYear. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withDayOfYear(4) Result: 2017-01-04T21:48:11.952 UTC (date changed to 01-04 since it is the 4th day of the year) |
Description | Returns a copy of this datetime with the hour of day field specified This is similar to the JavaScript withHourOfDay. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withHourOfDay(4) Result: 2017-11-06T04:48:11.952 UTC (hours changed to 4) |
Description | Returns a copy of this datetime with the millis of second field specified. This is similar to the JavaScript withMillisOfSecond. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withMillisOfSecond(4) Result: 2017-11-06T21:48:11.004 UTC (milliseconds changed to 4) |
Description | Returns a copy of this datetime with the minute of hour specified. This is similar to the JavaScript withMinuteOfHour. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withMinuteOfHour(4) Result: 2017-11-06T21:04:11.952 UTC (minutes changed to 4) |
Description | Returns a copy of this datetime with the month of year field specified. This is similar to the JavaScript withMonthOfYear. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withMonthOfYear(4) Result: 2017-04-06T21:48:11.952 UTC (month changed to 4) |
Description | Returns a copy of this datetime with the second of minute field specified. This is similar to the JavaScript withSecondOfMinute. | |
---|---|---|
Syntax |
| |
Example | If Expression: Date.now().withSecondOfMinute(4) Result: 2017-11-06T21:48:04.952 UTC (seconds changed to 4) |
Description | Returns a copy of this datetime with the year field specified. This is similar to the JavaScript withYear. | |
---|---|---|
Syntax |
| |
Example | If Expression: $Date.now().withYear(1995) Result: 1995-11-06T21:48:11.952 UTC (year changed to 1995) |
Video Tutorial: Working with Dates in a Mapper Snap