public Date and Time formatting

Contents [ show ]

By default, date format is taken from the platform's current regional setting.

You can set your own date format by using the date format option, present for all presentational and functional tags, which present dates. Example: {{published_date $|$ MM/dd/yyyy }}

The following masks can be used:

Day:

  • d - Day of month without a leading zero (e.g. 2 or 23)
  • dd - Day of month with a leading zero (e.g. 02 or 23)
  • ddd - Abbreviated week day name (e.g. Tue)
  • dddd - Full week day name (e.g. Tuesday)

Month:

  • M - Month without a leading zero (e.g. 4 or 12)
  • MM - Month with a leading zero (e.g. 04 or 12)
  • MMM - Abbreviated month name (e.g. Jan)
  • MMMM - Full month name (e.g. January)

Year:

  • y - Year without the century. No leading zero if value is less than 10 (e.g. 6)
  • yy - Year without the century with leading zero (e.g. 06)
  • yyyy - Full 4-digit year (e.g. 2006)

Hour:

  • h - Hour without a leading zero (e.g. 6 or 11). Should be used in combination with tt (AM or PM)
  • hh - Hour with a leading zero (e.g. 06 or 11). Should be used in combination with tt (AM or PM)
  • H - 24-hours clock. The hour without a leading zero (e.g. 6 or 11).
  • HH - 24-hours clock. The hour with a leading zero (e.g. 6 or 11).

Minute:

  • m - Minute without a leading zero (e.g. 2 or 35)
  • mm - Minute with a leading zero (e.g. 02 or 35)

Second:

  • s - Second without a leading zero (e.g. 9 or 59)
  • ss - Second with a leading zero (e.g. 09 or 59)

All of the above combinations will be replaced when encountered.
To not convert a format string, enclose it within single quotes:

'ddd' will not be converted, but day without quotes will become 23a6 for June 23, 2006,
so it should be enclosed within single quotes.

Last edited by nadia on 27 Oct 2010 | Rev. 2 | This page is public | Views: 1
Comments: 0 | Filed under: root | Tags: