Change Time Format
Question
How can I change the format of dates and times?
How do I change the time zone for PmWiki's dates and times?
?
PmWiki?
Answer 1: Changing PmWiki's time output format
1: PmWiki
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 (%M), and am/pm setting (%p).
The documentation for strftime describes the various %-parameters that are available.
PmWiki$TimefmtPHPstrftime
$TimeFmt
"%B %d, %Y, at %I:%M %p"
(d)(I)(%M)/(%p)
strftime%
Thus, to change the display of dates and times to a "mm-dd-yyyy hh:mm" format, set $TimeFmt
in local/config.php as
"mm-dd-yyyy hh:mm"
local/config.php$TimeFmt
$TimeFmt
='%m-%d-%Y %H:%M'; # mm-dd-yy hh:mm$TimeFmt
="%d.%m.%G, at %R %Z"; # german (ISO year) format
Answer 2: Setting the time zone
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 NZS-12NZD New Zealand Standard/Daylight Time
See Also
http://www.timeanddate.com/library/abbreviations/timezones/
Contributor
- Reinhard Hofmann
- Pm
Categories: