Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In this Page

...

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


Code Block
Date.parse(dateString)

This method has the following extensions from the standard:

  • parse(millisFromEpoch) - Return a date object that is initialized with the given number of milliseconds from the epoch. If the parameter to parse() is a number, it will be treated as the number of milliseconds from the epoch (Jan 1, 1970) and a new date object will be created and initialized with that value.
  • parse(dateStringformat) - Parse a date string using a custom format. The second argument is a format string using the same syntax as the Java SimpleDateFormat class.
  • parse(dateNumber, format) - Parse a number as a date using a custom format. The second argument is a format string using the same syntax as the Java SimpleDateFormat class. The number converts to a string and parsed using the given format.
Example

Expression: Date.parse(1445910469510)

Result: 2015-10-27T01:47:49.510 (in the server's timezone)


Expression: Date.parse("2011 10 30", "yyyy MM dd")

Result: 2011-10-30T00:00:00.000 (in the server's timezone)


Expression: Date.parse ($['System Modstamp'],"MM/dd/yyyy'T'HH:mm:ss.SSS'Z'")

Result: 2015-04-15T13:23:10.000 (in the server's timezone)


Expression: Date.parse(20160923, “yyyyMMdd”)

Result: 2016-09-23T00:00:00.000 (in the server's timezone)

...

DescriptionThis 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


Code Block
dateobject.getTime()


Example

Expression: Date.now().getTime()

Result: 1487712862069

getUTCDate

Description

Converts the specified time to its corresponding UTC time

Syntax


Code Block
dateobject.getUTCDate()


Example

Expression: Date.parse("2019-03-04T17:32:53.077").getUTCDate()

Result: 4

...

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:

  • format: Describes the format of the returned string. See the Joda DateTimeFormat documentation for the full details.
  • timeZone: Specifies the target time zone. Use the Canonical ID value from Joda-Time.
  • locale: Specifies the language tag.
Note

Earlier versions of this method would accept a JSON-encoded string as the options object. However, due to the performance impact of parsing this string, it is recommended that an object literal be used to pass the options instead. If your pipeline passes a string argument, a warning will be raised during execution.

This is similar to the JavaScript toLocaleDateTimeString.

Syntax


Code Block
dateobject.toLocaleDateTimeString()


Example

Expression: Date.parse("20142024-0903-2229").toLocaleDateTimeString()

Result: 2014 2024-0903-22T0029T00:00:00.000


Expression:

Date.parse("2024-03-28T16:23:59.825").toLocaleDateTimeString({"timeZone":"US/Eastern", "format":"yyyy-MM-dd HH:mm a"})

Date.now().toLocaleDateTimeString({"locale":"ar-EG"})

Image Added

Result: 2024-03-28 12:23 PMImage Removed


For the {"timeZone":"zoneValue"} option, you can use the Canonical ID value from Joda-Time.


Expression

Date.now().toLocaleDateTimeString({"locale":"ar-EG"})

Date.now().toLocaleDateTimeString({"locale":"fa-IR"})

Date.now().toLocaleDateTimeString({"locale":"en-US"})

Result


...

toLocaleDateString

Description

Format the date using the given format as described in an object.

Syntax


Code Block
$datetime.toLocaleDateString(format)


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


Code Block
$datetime.plus(value)


Example

If Date.now() is 2017-11-06T21:48:11.952 UTC

Expression: Date.now().plus(2)

Result: 2017-11-06T21:48:11.954 UTC 

(last digit increased by 2)


Expression: Date.now().plus(20)

Result2017-11-06T21:48:11.972 UTC

(second to last digit increased by 2)


Expression: Date.now().plus(2000)

Result2017-11-06T21:48:13.952 UTC

(fourth digit from the end increased by 2)

plusDays

Description

Returns a copy of this datetime plus the specified number of days. 

This is similar to the JavaScript plusDays.

Syntax


Code Block
$datetime.plusDays(value)


Example

If Date.now() is 2017-11-06T21:48:11.952 UTC

Expression: Date.now().plusDays(2)

Result: 2017-11-08T21:48:11.952 UTC

(day value increased by 2)

plusHours

Description

Returns a copy of this datetime plus the specified number of hours. 

This is similar to the JavaScript plusHours.

Syntax


Code Block
$datetime.plusHours(value)


Example

If Date.now() is 2017-11-06T21:48:11.952 UTC

Expression: Date.now().plusHours(2)

Result: 2017-11-06T23:48:11.952 UTC

(hour increased by 2)

...