ChangeTimeFormat
Questions answered by this recipe
- How do I change the time format?
- How can I display dates and times in a different timezone?
Changing PmWiki's time output format
PmWiki uses the $TimeFmt variable and PHP's strftime function to format its dates and times. The default setting of $TimeFmt is "%B %d, %Y, at %I:%M %p", which displays the name of the month (d), year (I), minutes (p). The documentation for strftime describes the various %-parameters that are available.
Thus, to change the display of dates and times to a "mm-dd-yyyy hh:mm" format, set $TimeFmt in local/config.php as
$TimeFmt='%m-%d-%Y %H:%M'; # mm-dd-yy hh:mm$TimeFmt="%d.%m.%G, at %R %Z"; # german (ISO year) format$TimeFmt='%F %R'; # yyyy-mm-dd hh:mm - International Standard ISO 8601$TimeFmt='%Y %b %a %e %R'; # logical-scale full: (example: 2007 Jan Fri 26 00:29)
Setting the time zone on PHP 5.1 or newer
The timezone setting allows for all time stamps in RecentChanges, in the page histories and in the author signatures to be in a specific timezone. If your hosting provider is located in your timezone, it may already be correctly configured without you needing to do anything. If it is not, here is how to change it.
Set to config.php something like:
date_default_timezone_set('America/New_York');
There is a list of defined timezone identifiers, you can find yours starting from this page: List of Supported Timezones.
Setting the time zone on PHP 5.0 or older
To change your timezone, you generally need to know the value of the "TZ" or "timezone" environment variable. These are defined for different localities around the world. For example, in the U.S. the Eastern time zone setting is generally "EST5EDT", which gives the name of the timezone ("EST"), the number of hours offset from GMT (5), and a string to be used if the zone honors daylight savings time ("EDT").
Thus, to change PmWiki's timezone to be U.S. Eastern Time, add the following line to local/config.php.
putenv("TZ=EST5EDT");
Some common timezone values (feel free to add to this list):
EST5EDT U.S. Eastern Standard/Daylight Time
CST6CDT U.S. Central Standard/Daylight Time
MST7MDT U.S. Mountain Standard/Daylight Time
MST7 U.S. Mountain Standard Time (Arizona)
PST8PDT U.S. Pacific Standard/Daylight Time
AKST9AKDT U.S. Alaska Standard/Daylight Time
UTC0 Universal Coordinated Time
GMT0 Greenwich Mean Time
CET-1CEST Central Europe Time/Central Europe Summer Time
CET1CEST Actual Central Europe Time (Amsterdam/Frankfurt/Oslo/Paris/Rome/Madrid/Geneva)
NZS-12NZD New Zealand Standard/Daylight Time
AEST / AEDT Australian Eastern Standard Time (UTC +10) / Australian Eastern Daylight Time (UTC +11)
WAUST-8WAUDT Western Australia Standard/Daylight Time
America/Sao_Paulo Brazil Standard time (don't forget the underscore)
JST Japan Standard Time
MSK Moscow/Saint-Petersburg
IST Indian Standard Time
SAST South Africa Standard Time (UTC + 2 hours)
EST-5 Jamaica Standard Time (UTC -5)
See Also
- http://en.wikipedia.org/wiki/List_of_tz_zones
- List of Supported Timezones
- Cookbook:LocalTimes - if you have readers and editors who are located in different time zones, this addon rewrites the time stamps in the timezone of the browser.
Contributor
- Reinhard Hofmann
- Pm
Comments
See discussion at ChangeTimeFormat-Talk