$Web_D2Date, $Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date

From m204wiki
Jump to navigation Jump to search

$Web_N2Date, $Web_ND2Date, $Web_NM2Date, $Web_NS2Date: Convert number to date


The $Web_xx2Date functions convert a numeric date/time value into date/time strings. The returned string is in the format "Wkd, DD Mon YYYY HH:MI:SS GMT". The $Web_xx2Date functions take one argument and return a string or null in the event of a conversion error.

Syntax

%datestring = $Web_D2Date(datetime) %datestring = $Web_N2Date(datetime) %datestring = $Web_ND2Date(datetime) %datestring = $Web_NM2Date(datetime) %datestring = $Web_NS2Date(datetime)

Syntax terms

datetime This is the number of time units since 12 AM, January 1, 1900. The time is assumed to be in Greenwich Mean Time (GMT). This is a required parameter.

Usage notes

  • The input time units for the various flavors of $Web_xx2Date are ;
    $Web_D2Date Number of seconds since midnight, January 1, 1900.
    $Web_N2Date Number of seconds since midnight, January 1, 1900.
    $Web_ND2Date Number of days since midnight, January 1, 1900.
    $Web_NM2Date Number of milliseconds since midnight, January 1, 1900.
    $Web_NS2Date Number of seconds since midnight, January 1, 1900.
  • $Web_D2Date produces identical results to $Web_NS2Date so, for clarity and consistency, it is recommended that $Web_NS2Date be used instead of $Web_D2Date, since $Web_NS2Date indicates the time units for the input (number of seconds) and the format of the input data (numeric).

Examples

The most likely uses of these functions is for displaying debugging information (perhaps to the audit rail) or setting an HTTP response header parameter that requires a web time value, though most of the useful response headers are better accessed through special purpose $functions such as $Web_Expire and $Web_Last_Modified.

In the following example, the HTTP 1.1 response header called "Retry-After" is set as two minutes later.

%CURR_TIME = $Web_DateNS %RETRY_TIME = $Web_NS2Date(%CURR_TIME + 2 * 60) %RC = $Web_Response('Retry-After', - %RETRY_TIME)

Even this example is a bit of a stretch, since the value for "Retry-After" can be expressed as a number of seconds later instead of a date/time string.

See also