monster.util.toFriendlyDate(timestamp[, format, user]);


timestamp: Number OR Date (mandatory)

Gregorian timestamp or JavaScript Date to transform in friendly date.

format: String (optional, default: dateTime)

The following strings (not case-sensitive) can be used for pre-set formats: shortDateTime: 'MM/DD/YY - hh:mm' dateTime: 'MM/DD/year - hh:mm:ss' shortDate: 'MM/DD/YY' shortTime: 'hh:mm' time: 'hh:mm:ss', calendarDate:'month DD, year' * date: 'MM/DD/year'

Set of characters that will be replaced to render the date following those rules: year: full year YY: last two digits of the year month: name of the month MM: month in a two digit format day: name of the day DD: date of the day hh: hours mm: minutes ss: seconds 12h: AM/PM suffix (if not specified, hours will be displayed in a 24h format), * ordinal: the ordinal suffix of the day (st, nd, rd or th)

Note: The date (M/D/Y, D/M/Y, or Y/M/D) and time (12h or 24h) formats will be automatically set according to the user's preferences. It is not advised to set them manually.

user: Object (optional, default: monster.apps.auth.currentUser)

The user from which to get the date and time preferences. This will be the currently logged-in user by default.


This method returns a String representation of a date.


This method formats a Gregorian timestamp or a JavaScript Date into a string representation of the corresponding date. This representation can be customized by specifying the format parameter.


  • Create a friendly date
var date = new Date(2015, 2, 24);

// output: "24/03/2015 - 00:00:00"
  • Create a friendly date with custom formats
var jsDate = new Date(2015, 2, 24),
    gregorianTimestamp = monster.util.dateToGregorian(jsDate),
    timeDate = monster.util.toFriendlyDate(gregorianTimestamp, 'time - date'),
    shortDate = monster.util.toFriendlyDate(jsDate, 'shortDate'),
    verbose = monster.util.toFriendlyDate(gregorianTimestamp, 'day, DDordinal of month year');

// output: "00:00:00 - 24/03/2015"

// output: "24/03/15"

// output: "Tuesday, 24th of March 2015"

Edit this page here