Date Formatting

Top  Previous  Next

Date Formatting Characters:

Format

Meaning

yyyy

Four-digit year

yy

Two-digit year

mm

Two-digit month

mmm

Short month name

mmmm

Long month name

dd

Two-digit day of month

ddd

Week day name (short)

dddd

Week day name (long)

hh

Two-digit hour (in 24 hours base)

nn

Minutes

ss

Seconds

s

First digit of Milli-seconds

Integer

The date is in integer format

Parse

The date string should be parsed with Date.parse() function

 

 

The Current Date

If the reserved word "today" is used as a date value it is substituted with the current date according to the browser's clock. To get the current day from the server computer's clock servertime built in data source can be used.

Example:

           mo:props="
              ...
              defaultDate     : 'today',  // Use browser's clock
              fromDate        : '{/root/servertime/time}', // Use server's clock
              toDate          : '{/root/servertime/time} +1y', 
           "

Note that a Data Request should be defined in the Page Configuration in order to use the servertime data source as follows:

<dataRequest name="servertime" />

 

Relative Date Definitions

When defining a date in mo:iValue attribute or in defaultDate, fromDate, toDate properties the relative date definitions can be made after the date value.

           mo:iValue="{ORDERDATE} -1d" // One day ago from the order date
           mo:props="
              defaultDate     : 'today -1m', // One month ago from today
              fromDate        : '{/root/servertime/time} -1y', // One year ago from today 
              toDate          : '{/root/servertime/time} +1m'  // One month later from today
           "

Note that at least one space character should exists between the date value and the relative date definition.