ft-date-format provides javascript utilities for formatting and updating dates in FT style.
Returns a date formatted as a string
date
: A javascriptDate
object or a valid string to pass to theDate
constructortpl
: A string specifying what format to output the date in:'datetime'
: formats the date in the standard FT long format, including the time. E.g.May 15, 2014 8:10 am
'date'
: formats the date in the standard FT long format. E.g.May 15, 2014
- Any other string using widespread conventions for time/date placeholders, which will be replaced with values extracted from the date provided. See
./main.js
for an up to date list of supported formats. To avoid e.g. themm
incommon
being replaced with the month prefix with a double backslashco\\mmon
i.e. In most cases custom date formats should not be used, in favour of the standard FT date and datetime formats
Returns the relative time since the given date, formatted as a human readable string e.g. 13 minutes ago
.
Returns relative time or timestamp for a given date, in accordance with FT date formatting conventions.
date
: A javascriptDate
object or a valid string to pass to theDate
constructor
Returns 'yesterday'
, 'today'
or ''
for a given date. You can request this formatting for ft-date-format
components by adding data-ft-date-format-format="today-or-yesterday-or-nothing"
.
date
: A javascriptDate
object or a valid string to pass to theDate
constructor
State | Major Version | Last Minor Release | Migration guide |
---|---|---|---|
✨ active | 2 | N/A | migrate to v2 |
⚠ maintained | 1 | 1.0.5 | - |
If you have any questions, comments, or need help using ft-date-format, please either raise an issue, visit #ft-origami or email Origami Support.
This software is published by the Financial Times under the MIT licence.