EZDate
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?
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:
Default formatting code:
(:ezdate:)
. The current time is (:eztime:)
.
will display like this:
Formatted code:
(:ezdate "M j, Y h:i:s a":)
will display like this:
TimeStamp code:
(:ezdate "M j, Y h:i:s a" 1175680596:)
will always display this:
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:
or in your farmconfig.php enter:
$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
- ftime markup expression
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.