formatTimeUTC()

Returns the UTC time in a particular format.

Synopsis

string formatTimeUTC(string format, time t[, string milliFormat]);

Parameters

Parameter Description
format

Output format (without milliseconds) or in HTTP or ISO format.

If you specify the

" HTTP" format, the function returns the UTC time in HTTP format and the milliseconds (string milliFormat) are ignored (see RFC 2616).

if you specify the

"ISO" format returns the UTC time in ISO format in a dateTime string.

t time
milliFormat Output format for the milliseconds

Return value

The function returns the UTC time format as a string or in the event of errors an empty string.

Error

With incorrect variable types or invalid arguments

Description

The function formatTimeUTC() determines the UTC time of the given time t in a format defined by the arguments format and milliFormat. The string format contains the formatting with an accuracy of seconds. The parameters available for this are those of the function strftime() of the ANSI C standard (see formatTime()).

The format fprintf() is used in the optional string milliFormat to specify milliseconds. The corresponding output will be appended to the expression generated by the first format specification.

Example

The following example outputs the week in the year, date and time in the local time (localTime) and UTC time (utcTime).

main()
{
  time t1;
  string localTime;
  string utcTime;
  setTime(t1,2010,6,1,15);
  localTime = formatTime("%W; %c", t1, " ms: %04d");
  utcTime = formatTimeUTC("%W; %c", t1, " ms: %04d");
  DebugN("Local: ", localTime);
  //Output: ["Local: "]["22; 6/1/2010 3:00:00 PM ms: 0000"]
  DebugN("UTC: ", utcTime);
  //Output: ["UTC: "]["22; 6/1/2010 1:00:00 PM ms: 0000"]
}

The following example returns a UTC dateTime string in ISO and in HTTP formats.

main()
{
  string dt1, dt2;
  dt1 = formatTimeUTC("ISO", makeTime(2014, 6, 30, 18, 30, 3,
  7));
  dt2 = formatTimeUTC("HTTP", makeTime(2014, 6, 30, 18, 30, 3,
  7));
  DebugN("format time UTC/ISO:", dt1);
  DebugN("format time UTC/HTTP:", dt2);
}

As of the version 3.20 ISO projects cannot be created anymore. Create UTF-8 projects instead.

Assignment

Time function

Availability

CTRL