You are here: Reference > Date/Time Format Syntax > nwadateformat Modifier

nwadateformat Modifier

The date format takes one or two arguments – the format description and an optional default value (used if there is no time/date to display). UTF-8 is the character encoding used throughout the application, as this covers languages such as Spanish that use non-ASCII characters.

The full list of special formats is:

Table 1: Date and Time Formats

Preset Name

Date/Time Format

Example

hhmmss

%H%M%S

141345

hh:mm:ss

%H:%M:%S

14:13:45

iso8601

%Y%m%d

20080407

iso8601t

%Y%m%d%H%M%S

20080407141345

iso-8601

%Y-%m-%d

2008-04-07

iso-8601t

%Y-%m-%d %H:%M:%S

2008-04-07 14:13:45

longdate

%A, %d %B %Y, %I:%M %p

Monday, 07 April 2008, 2:13 PM

rfc822

%a, %d %b %Y %H:%M:%S %Z

Mon, 07 Apr 2008 14:13:45 EST

displaytime

%l:%M %p

2:13 PM

recent

2 minutes ago

The % items on the right hand side are the same as those supported by the php function strftime().

The string “?:”, if present will return the string following the “?:” if the time value is 0. Otherwise, the format string up to the “?:” is used.

See Date/Time Format String Reference in this chapter for a full list of the supported date/time format string arguments.

Examples of date formatting using the nwadateformat SmartyTemplate engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. modifier are as follows:

{$u.expire_time|nwadateformat:"longdate"}
Monday, 07 April 2008, 2:13 PM

{$u.expire_time|nwadateformat:"iso8601"}
20080407

{$u.expire_time|nwadateformat:"iso-8601t"}
2008-04-07 14:13:45

{$u.expire_time|nwadateformat:"iso8601?:N/A"}
20080407   (or N/A if no time specified)

{$u.expire_time|nwadateformat:"%m/%d/%Y"}
04/07/2008