EZDate

Summary: make displaying the date, time, and PHP timestamp inside the wiki easy
Version: 1.5
Prerequisites: none
Status: Working
Maintainer:
Discussion: EZDate-Talk?
Categories: Markup PHP72
Downloads: EZDate.phpΔ

Questions answered by this recipe

  • How do I display the date, time, and timestamp in a wiki page using wiki code?
  • How do I display the date or time in a specific format in a wiki page?
  • How should I store a date so I can display it in any format I want?

This section is optional; use it to indicate the types of questions (if any) this recipe is intended to answer.

Description

Display date, time, or use a PHP timestamp in a wiki page.

This is easier than using MoreCustomPageVariables.

Syntax is easy. Use the form of page code like this:

(:ezdate:)
(:eztime:)
(:ezdate formattingstring:)
(:eztime formattingstring:)
(:ezdate formattingstring timestamp:)
(:eztime formattingstring timestamp:)

Default formatting code:

Todays date is(:ezdate:). The current time is (:eztime:).

will display like this:

Todays date is April 2, 2007. The current time is 5:04:56.

Formatted code:

(:ezdate "M j, Y h:i:s a":)

will display like this:

Mar 30, 2007 11:55:01 pm

TimeStamp code:

(:ezdate "M j, Y h:i:s a" 1175680596:)

will always display this:

Apr 4, 2007 04:56:36 am

Getting the current PHP timestamp

This recipe defines a custom pagevariable $EZTimeStamp. It can be used anywhere by putting it in braces.

The current PHP timestamp is {$EZTimeStamp}

The PHP timestamp is a great way to store a date because it can easily be displayed in any form using the EZDate recipe. This can be obtained in PHP by using the time() funtion.

Note:

Depending on the formatting (:ezdate:) can display time and (:eztime:) can display the date! They are both there for mnemonic convenience.

Date Formatting Information

Date formatting information is available at url

Installing

Copy EZDate.phpΔ to your cookbook directory

In your config.php enter:

include_once("cookbook/EZDate.php");

or in your farmconfig.php enter:

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

Notes

Release Notes

  • Version: 1.5 - adjust code to work with PHP 5.6
  • Version: 1.4 - ?? don't recall
  • Version: 1.3 - Add page variable $EZTimeStamp, improved code, executes only for specific actions.
  • Version: 1.2 - Change markup to (:ezdate:), add (:eztime:), set defaults
  • Version: 1.0 - Initial Release

See Also

Contributors

Comments

See discussion at EZDate-Talk?

User notes? : 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.