MODX Cloud

The Most Productive MODX Learning Playground Ever

Claim Free Lab Account

Date Formats

Skip to end of metadata
Go to start of metadata


MODx is written in PHP, and as such, it relies on the underlying PHP date functions, e.g. strftime. The discussion here can get quite tricky because the strftime and strtotime functions deploy similar arguments, but they are not identical. Sorry for the confusion; date manipulation and formatting is more complex than it might at first seem.

The discussion here relates primarily to the following content fields:

  • createdon
  • deletedon
  • editedon
  • publishedon
  • unpub_date

Common Examples.

It's not possible to give every possible example because date formatting can be complex, and it varies from region to region. Here are a few common examples that demonstrate how to use the output filters below.

Example Output The Filter Parameters
Thu Apr 14, 2011 [[*createdon:strtotime:date=`%a %b %e, %Y`]]
18 April 2011 [[*createdon:strtotime:date=`%e %B %Y`]]
Monday, April 18, 2011 [[*createdon:strtotime:date=`%A, %B %e, %Y`]]
2011-04-18 [[*createdon:strtotime:date=`%Y-%m-%d`]]

All Parameters

Code Display Example
%a Short weekday name Sun
%A Full weekday name Sunday
%b Short month name Jan
%B Full month name January
%c Local date and time Wed Jan 7 00:22:10 2010
%C Century (the year divided by 100, range 00 to 99) 20
%d Day of the month (01 to 31) 03
%D Same as %m/%d/%y 04/29/10
%e Day of the month (1 to 31) 3
%H Hour (24-hour clock) 00-23
%I Hour (12-hour clock) 01-12
%l (lower-case L)
Hour in 12-hour format, with a space preceding single digits 1-12
%j Day of the year 001 to 366
%m Month 01 to 12
%M Minute 00 to 59
%n Newline character \n
%p am or pm amz
%P AM or PM AM
%r Same as %I:%M:%S %p 08:23:11 PM
%R Same as %H:%M 23:11
%S Second 00 to 59
%t Tab character \t
%T Same as %H:%M:%S 26:12:27
%u Weekday (Monday=1) 01 to 07
%w Weekday (Sunday=0) 00 to 06
%x Date only 01/25/09
%X Time only 02:58:12
%y Two-digit year 09
%Y Four-digit year 2010
%Z or %z Time zone offset or name -005 or EST
%% A literal % character %

See Also

Labels

date date Delete
format format Delete
output output Delete
filters filters Delete
strtotime strtotime Delete
fuzzydate fuzzydate Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Jan 05, 2012

    Josh Gulledge says:

    FYI for those running on Windows from the PHP site: Additionally, not all platf...

    FYI for those running on Windows from the PHP site:

    Additionally, not all platforms support negative timestamps, so your date range may be limited to no earlier than the Unix epoch. This means that %e, %T, %R and, %D (and possibly others) - as well as dates prior to Jan 1, 1970 - will not work on Windows, some Linux distributions, and a few other operating systems. For Windows systems, a complete overview of supported conversion specifiers can be found at » MSDN.

    So the first 3 common examples given do not work on Windows!