For more information... RTFM!
NAVIGATION
RECENTLY VIEWED
PAGES THAT LINK HERE
ACCOUNT LOGIN

You are not logged in

Powered by Interchange version 5.7.0

convert_date

This filter calls the [convert-date] tag to format a date according to the specified format string.

The input date is expected to be in the "YYYY-MM-DD" format, with an optional "HH:MM:SS" time specification.

The parameter is expected to be a date/time specification, using the

POSIX strftime Link to an external page tokens listed here.  The default is "%d-%b-%Y %I:%M%p" if a time is provided, otherwise it is "%d-%b-%Y".

Also see the strftime filter.

Example

  1. [filter convert_date]2007-01-02[/filter]
  2. [filter convert_date]2007-01-02 22:15[/filter]
  3. [filter convert_date.%Y-%m-%d.%H:%M:%S]2007-01-02 22:15[/filter]
  4. [filter convert_date."%A %d %B %Y at %I:%M %p"]2007-01-02 22:15[/filter]

Results in:

  1. 02-Jan-2007
  2. 02-Jan-2007 10:15PM
  3. 2007-01-02 22:15:00
  4. Tuesday 02 January 2007 at 10:15 PM

Source code

sub {
    my $time = shift(@_);
    return '' unless $time;

    shift(@_);
    my $fmt = shift(@_);
    while(my $add = shift(@_)) {
        $fmt .= " $add";
    }
    return $Tag->convert_date({ fmt => $fmt, body => $time});
}

Category:  Filters
Last modified by: Kevin Walsh
Modification date: Monday 14 May 2007 at 7:20 PM (EDT)
Home  |  Legal nonsense  |  Privacy policy  |  Contact us