NP_BetterDate

General Plugin info
Author: Nate Silva
Current Version: 1.0
Download: Download the plugin (zip)
Code: NP_BetterDate_Code
Demo: -
Forum Thread: -

This plugin is an improved date function. The date() function in Nucleus is based on strftime(). This improved function is based on PHP's date() and gmdate(). It allows additional formatting options and better control over timezone presentation.

This plugin will allow you to use all the date format specifiers that the PHP date() function allows. In addition two special formats are provided (iso8601 and tzwithcolon).

Installation

  1. Copy the PHP code below into a file called NP_BetterDate.php.
  2. Or download the zip file (see above) and extract it
  3. Place the file in your Nucleus plugins directory.
  4. Install it from within Nucleus (Admin → Nucleus Management → Manage Plugins).
  5. Call it from a template (will not work from a skin).

TemplateVars

Syntax

<%BetterDate(datetype, format)%>

Where datetype is one of: posted, postedutc, now or nowutc. This returns either the timestamp of the current post, or the current date; in either local or UTC time.

format is a date format string. The syntax is exactly the same as PHP's date() function (here is a reference for format codes).

In addition, format may be one of the special values: iso8601 which will use the international standard format; or tzwithcolon, used in the issued tag of an Atom 0.3 feed (so your feed can validate with feeds.archive.org).

Examples

<!-- call this from a nucleus template -->
<%BetterDate(postedutc,iso8601)%>
<%BetterDate(posted,B)%>  <!-- Swatch Internet time -->
<%BetterDate(posted,l \t\h\e jS)%>  <!-- something like 'Saturday the 8th' -->
<%BetterDate(now,iso8601)%>
<%BetterDate(nowutc,iso8601)%>
<%BetterDate(posted,tzwithcolon)%>  <!-- for 'issued' tag of Atom feed to validate -->

Plugin Review

NP_BetterDate version 1.0 works with Nucleus CMS version 3.31 - 2007-10-30 kg

betterdate.txt · Last modified: 2007/10/30 18:24 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki