Format - Dates

Category : Technical Examples

Docmosis allows you to control how dates and times are displayed in the finished document.

For example: the raw data may have a date like: 21-03-16.

Using the built-in function formatDate the date can be formatted so that it looks like this: Monday - March 21, 2016

Data Files
Output Files
All Files as a ZIP

This example explained

It is best to view the TEMPLATE and OUTPUT files side-by-side to understand the formatting that has been applied.


The function formatDate has upto three parameters:

    dateFormat ( value [, outputFormat [, inputFormat] ])

The value is the Date/Time to be formatted.

The other two are the format strings, enclosed in single quotes.

The format strings are used to tell Docmosis

    1) inputFormat - How to decode the value that is passed in.

    2) outputFormat - How to display the value once it is decoded.


Here is an example of a format string: 'dd-MMMM-yyyy'.

The format strings are optional.  If they are not provided - Docmosis will use the default settings.


Some characters in the string are obvious:

    dd - for a two digit day

    yyyy - for a four digit year.


Other combinations are not so obvious:

    MM - is the Month in numeric form.

    MMM - is the Month abbreviated to the first three letters.

    MMMM - is the Month as a full word.

    mm - is for minutes.

    EEEE - the day expressed as a word.

    EEE - the day abbreviated to the first three letters.

    hh - is for hours in 12 hour notation.

    HH - is for hours in 24 hour notation.

    aa - is for AM/PM.


You will find the complete list in the Docmosis Template Guide [PDF].


LEARN MORE: Download our Docmosis Quick Reference [PDF].