TimeZones

Summary: Display all dates and times in user selectable timezone and format
Version: 2007-10-28d
Prerequisites:
Status: alpha
Maintainer: Petko

Note, the development of this recipe is suspended. Check out the newer recipe Cookbook:LocalTimes which is now part of the PmWiki core.

Questions answered by this recipe

Can I display all timestamps on PmWiki (last modified times in recent changes, page history or pagelists, or in user signatures) in my own time zone? Calculating time differences to know how long ago the page was modified is annoying, especially if I work on several wikis in different timezones.

Can I also select my own time format? In the US, dates are written Month/Day/Year, while in Europe it is Day/Month/Year and it may be very confusing. Also, some users prefer a 24-hours-clock instead of 12-hours plus AM/PM.

Installation

Get timezones.phpΔ, place it in your /cookbook/ directory and add to config.php the line:

 include_once("$FarmD/cookbook/timezones.php");

Description

Display all dates and times (in recent changes, pagelists, signatures) in user selectable timezone and format.

This recipe will be usefull to people working collaborately on one wiki, while being located in different parts of the world and in different timezones.

Users call a new wiki "action", like [[{$FullName}?action=tz]] ("tz" from "time zone") and select their time offset from UTC. They can also select the time format, as defined in the strftime function. Their preferences are stored in a cookie, and then all timestamps will be displayed according to their selection.

Every date and time value, for example in RecentChanges, is replaced with a human readable timestamp in the UTC time zone like this: (:20071028T022117Z:) (means 2007-10-28 at 02:21:17 UTC). When a page is browsed, the timestamp is shown with the user-selected format and timezone (defaults to the server timezone and $TimeFmt if nothing defined by the user).

If a user signs his message on discussion pages (with ~~~~ four tildes), a similar UTC-timestamp is replaced on page save.

The existing page variable {*$LastModified} is replaced to the new intelligent format; it can be used for the current page, or {OtherPage$LastModified} for other page. In pagelists you can use the {=$LastModified} variable.

The new markup (:tzform:) displays a form for selecting the timezone offset.

Demonstration page.

Notes

1. Only timestamps added after the installation of the recipe can be displayed in user-selectable formats. This means, RecentChanges entries for newly modified pages, and new signed comments. On the other hand, the {=$LastModified} variable works for older pages too.

2. Currently the timestamps in the page history cannot be modified without a change to pagerev.php from the pmwiki core distribution. With the current version, page histories are displayed at servertime and with the default $TimeFmt.

Release Notes

2007-10-28c, d

  • Code rewritten: fixed to work with Safe mode too. Instead of location timezones, users enter the offset (automatically calculated by a piece of javascript).

2007-10-28

  • Initial release.

See Also

Cookbook /
LocalTimes  Display RecentChanges and History timestamps in the local timezone of each visitor. (Beta)

Contributors

  • Petko (used some code from Pm's crypt.php).

Comments

User notes -1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.