4.77. time

4.77.1. Summary

Parameters: locale

Positional parameters in same order.

The attribute hash reference is passed after the parameters but before the container text argument. This may mean that there are parameters not shown here.

Must pass named parameter interpolate=1 to cause interpolation.

This is a container tag, i.e. [time] FOO [/time]. Nesting: NO

Invalidates cache: no

Called Routine:

ASP-like Perl call:

    $Tag->time(
        {
         locale => VALUE,
        },
        BODY
    )

 OR

    $Tag->time($locale, $ATTRHASH, $BODY);
    [time locale other_named_attributes]
Parameters Description Default
adjust Temporarily adjust the time for display purposes. none
gmt Display time as GMT. none
locale Format the time according to the named locale. none
tz Use the passed timezone to display the time. none
zerofix Strips leading zeroes from numbers. none
Attributes Default
interpolate No
reparse Yes
Other_Characteristics  
Invalidates cache no
Container tag Yes
Has Subtags No
Nests No

Tag expansion example:

    [time locale]
---
    TODO: (tag result)

ASP-like Perl call:

   $Tag->time(  { locale => VALUE_locale
}, $body  );

or similarly with positional parameters,

    $Tag->time(locale, $attribute_hash_reference, $body);

4.77.2. Description

Formats the current time according to POSIX strftime arguments. The following is the string for Monday, January 1, 2001.

    [time]%A, %B %d, %Y[/time]

See the strftime man page for information on the arguments (which are the same as modern UNIX date commands).

Accepts the following options:

4.77.2.1. adjust

If you wish to temporarily adjust the time for display purposes, you can pass an adjust parameter with the number of hours (plus or minus).

        [time]%c[/time]
        [time adjust="-3"]%c[/time]

Will display:

 Mon 01 Jan 2001 11:29:03 AM EST
 Mon 01 Jan 2001 08:29:03 AM EST

If the number ends in zero and has 3 digits or more, it is assumed that the number is in timezone format (i.e +500) the local time or from GMT:

        [time]%c[/time]
        [time adjust="-330"]%c[/time]
        [time adjust="-300"]%c[/time]

Will display:

 Mon 01 Jan 2001 11:29:03 AM EST
 Mon 01 Jan 2001 07:59:03 AM EST
 Mon 01 Jan 2001 08:29:03 AM EST

If you want to force the number to be just a number of hours, add the hours parameter:

        [time]%c[/time]
        [time adjust="100" hours=1]%c[/time]

Will display:

 Mon 01 Jan 2001 11:29:03 AM EST
 Fri 05 Jan 2001 15:29:03 PM EST

If adjust is an Interchange time duration with a suffix of sec, min, hrs, days, or weeks, that will be used.

        [time]%c[/time]
        [time adjust="2 days"]%c[/time]

Will display:

 Mon 01 Jan 2001 11:29:03 AM EST
 Wed 03 Jan 2001 11:29:03 AM EST

Note that the time zone does not change -- you should either pick a format which doesn't display zone, use the tz parameter, or manage it yourself.

NOTE: You can adjust time globally for an Interchange installation by setting the $ENV{TZ} variable on many systems. Set TZ in your environment and then restart Interchange:

        ## bash/ksh/sh
        TZ=PST7PDT; export TZ
        interchange -restart

        ## csh/tcsh
        setenv TZ PST7PDT
        interchange -restart

On most modern UNIX systems, all times will now be in the PST zone.

4.77.2.2. gmt

If you want to display time as GMT, use the gmt parameter:

        [time]%c[/time]
        [time gmt=1]%c[/time]

will display:

        Mon 01 Jan 2001 11:33:26 AM EST
        Mon 01 Jan 2001 04:33:26 PM EST

Once again, the zone will not be set to GMT, so you should pick a format string which doesn't use zone, use the tz parameter, or manage it yourself.

4.77.2.3. locale

Format the time according to the named locale, assuming that locale is available on your operating system. For example, the following:

        [time locale=en_US]%B %d, %Y[/time]
        [time locale=fr_FR]%B %d, %Y[/time]

should display:

        January 01, 2001
        janvier 01, 2001

4.77.2.4. tz

Use the passed timezone to display the time. Will adjust for hours difference.

Example:

        [time tz=GMT0]
        [time tz=CST6CDT]
        [time tz=PST8PDT]

will display:

        Mon 01 Jan 2001 04:43:02 PM GMT
        Mon 01 Jan 2001 10:43:02 AM CST
        Mon 01 Jan 2001 08:43:02 AM PST

Note that the first alphabetical string is the zone name when not under daylight savings time, the digit is the number of hours displacement from GMT, and the second alphabetical string is the zone name when in daylight savings time. NOTE: This may not work on all operating systems.

4.77.2.5. zerofix

Strips leading zeroes from numbers.