Phone API Reference - Extended - localization_date.format
localization_date.format
Description
Formats an RFC822 or ISO 8601 date string and displays a localized date based on the phone's preferred locale.
For example, take the thirtieth day in the month of April for the year 2013. For the US locale, the phone would display 04/30/2013. If your phone's localization setting were set to the UK and you used this library, your display would read 30/04/2013.
Basic Example:
var formattedDate = localization_date.format(parameters); |
Additional display behaviors:
Current day, returns the time.
Day previous, returns Yesterday.
Within the last seven days, returns day of the week (i.e., Monday).
More than seven days in the past returns a short or long date, in the format associated with the phone's chosen locale.
Parameters
Name | Required | Type | Default | Description |
---|---|---|---|---|
date | Yes | string | 2020-04-30 10:58:01 | RFC822 or ISO 8601 date string |
version | No | string | short | Format of response string. Can be long or short. Defaults to short. Long includes the time. |
Examples
date.format with different versions
var dateString = date.format({ 'date' : '1985-08-11', 'version' : 'short' }); // sets dateString to '8/11/85' dateString = date.format({ 'date' : '1985-08-11', 'version' : 'long' }); // sets dateString to '11/8/85 0:00' |