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:
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||
|18 April 2011||
|Monday, April 18, 2011||
|%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|
|%P||am or pm||am|
|%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||Same as %H:%M:%S||26:12:27|
|%u||Weekday (Monday=1)||01 to 07|
|%w||Weekday (Sunday=0)||00 to 06|
|%Z or %z||Time zone offset or name||-005 or EST|
|%%||A literal % character||%|
- The above were gleaned from one of Bob's helpful forum posts: http://modxcms.com/forums/index.php?topic=56339.0
- Using Snippets
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!
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).