parseDate

Parses a date/time to allow evaluation and arithmetic.

Dates convert to milliseconds when used with standard comparison operators. For example, the expression (60*60*1000) equals one hour.

A common usage of this function is to adjust the current time using a multiplication expression that represents a number of seconds, minutes, hours, or days.

Type and Usage

Parameters

The only parameter is an expression to be parsed.

Output

Returns a Java date object, which is converted to a string for display.

Example

Each of the following expressions returns the date and time one day in the past:

<$parseDate(dateCurrent(-1))$>
<$parseDate(dateCurrent()-(24*60*60*1000))$>
<$dateCurrent(-1)$>
<$dateCurrent()-(24*60*60*1000)$>

Returns the time one hour in the future. The first line adds one hour using a time multiplication expression, assigns that time and date to a custom variable, and suppresses the output. The second line references the custom variable and defines that only the time is displayed:

<$exec my_customParseTime parseDate(dateCurrent()+(1000*60*60))$>
<$formatTimeOnly(my_customParseTime)$>

Returns the date one year in the future. The first line adds one year using a time multiplication expression, assigns that time and date to a custom variable, and suppresses the output. The second line references the custom variable and defines that only the date in long format is displayed:

<$exec my_customParseTime parseDate(dateCurrent()+(1000*60*60*24*365))$>
<$formatTimeOnly(my_customParseTime)$>

This script evaluates whether the date seven days in the future is greater than the expiration date and returns a message to the user if true:

<$if dOutDate$>
    <$if dateCurrent(7) > parseDate(dOutDate)$>
Content item expires in one week.
     <$endif$>
<$endif$>

This script uses parseDate within a conditional statement for customized workflow jumps. The script specifies that if the last time we entered this step was four days ago, go to the first step in workflow wf_late and set the return step to be the next step:

<$if parseDate(wfCurrentGet("lastEntryTs")) < dateCurrent(-4)$>
    <$wfSet("wfJumpName", "lateJump")$>
    <$wfSet("wfJumpTargetStep", "step_1@wf_late")$>
    <$wfSet("wfJumpReturnStep", wfCurrentStep(1))$>
    <$wfSet("wfJumpEntryNotifyOff", "0")$>
<$endif$>

See Also