setTime()

Sets a time to the value specified in the argument.

Synopsis

time setTime(time &t, unsigned year, unsigned month, unsigned day [, unsigned hour [, unsigned minute [, unsigned second [, unsigned milli [, bool daylightsaving]]]]]);

Parameters

Parameter Description
t Time to be set
year Year
month Month
day Day
hour Hours
minute Minutes
second Seconds
milli Milliseconds
daylightsaving Summer or winter time

Return value

Equal to the value of t, in the event of errors 0 [1970.1.1 00:00:00.000000000] (UTC)

Errors

missing/incorrect arguments

Description

The function setTime()sets the time variable t to the value specified in the argument. The default value of the optional arguments hour , minute, second and milli is zero. A minimum series of arguments is therefore "1996, 3, 5" for the 5th March 1996, exactly zero hours. The argument "daylightsaving" specifies whether the time is to be understood as summer or winter time: Values are "TRUE" or "FALSE". Depending on the transferred time (summertime/wintertime), the default is either "TRUE" or "FALSE".

Assure, that the change from daylight saving to local time is either managed by the system or by a radio clock. If both techniques are used, this can cause a double change of time.

Example

main()
{
  time t;
  setTime(t, 1999,8,17);
}

The example below sets the time to null time = 1.1.1970.

main(mapping event)
{
  time nullTime;
  setTime(nullTime, year((time)0), month((time)0), day((time)0), hour((time)0), minute((time)0), second((time)0));
  DebugN("Time:", nullTime);
}

The example outputs the UTC time: WCCOAui1:["Time:"][1970.01.01 00:00:00.000000000]

Under some operating systems such as CentOS a date before 1970 exists.

Assignment

Time function

Availability

CTRL