Time


Most of these functions must be called with two arguments, here designated time_t and time_zone. time_t is the number of seconds since the beginning of C.U.T. (Coordinated Universal Time) at 00:00:00 January 1, 1970. This value can be obtained from the system variables time_t and dyn_time_t (time_t is set when the script starts executing; dyn_time_t is updated at the moment that it is used; which one you use depends on what your program does).

time_zone is the number of hours before or after GMT; this value can be obtained using the built-in function timezone(). Here is an example of how a time function can be called:

Note: These functions cannot be used to process dates earlier than January 1, 1970, or later than January 19, 2038.

Name -- Syntax / Description
mktime_t
mktime_t( year, month, dayofmonth, hours, minutes, seconds, timezone )
Returns the s.time_t value for the time specified. time_zone can be the keyword 'local'
time_t_dayofmonth
time_t_dayofmonth( timet, time_zone )
Returns the current month as a number. time_zone can be the keyword 'local'
time_t_dayofweek
time_t_dayofweek( timet, time_zone )
Returns the current day of the week as a number (Sunday=1). time_zone can be the keyword 'local'
time_t_dayofyear
time_t_dayofyear( timet, time_zone )
Returns the number of days since the beginning of the year, including today. time_zone can be the keyword 'local'
time_t_hour
time_t_hour( timet, time_zone )
Returns current hour (using a 24-hour clock). time_zone can be the keyword 'local'
time_t_min
time_t_min( timet, time_zone )
Returns the current minute in the hour. time_zone can be the keyword 'local'
time_t_month
time_t_month( timet, time_zone )
Returns the current month as a number. time_zone can be the keyword 'local'
time_t_sec
time_t_sec( timet, time_zone )
Returns the current second in the minute. time_zone can be the keyword 'local'
time_t_year
time_t_year( timet, time_zone )
Returns the current year, time_zone can be the keyword 'local'
timezone
timezone()
Returns an integer which is the number of hours behind or ahead of GMT (not accounting for Daylight Time)
User Annotations: time
Ray Yates : mivascript at, pcinet d0t com
02/09/2012 13:04 p.m.
The following code will perform a "time delay", during which the program appears to do nothing. The value of the variable wait is the number of seconds to delay.
<MvFUNCTION NAME = "delay" PARAMETERS = "wait" STANDARDOUTPUTLEVEL = "">
    <MvASSIGN NAME = "l.stop" VALUE = "{ s.dyn_time_t + l.wait}">
    <MvWHILE EXPR = "{ s.dyn_time_t LE l.stop }">
    </MvWHILE>
</MvFUNCTION>
Ray Yates : mivascript at, pcinet d0t com
09/26/2011 09:34 a.m.
The Time2Seconds(time_string) function below takes a time string in the form 'hh:mm:ss' and converts it to seconds: For example: the time '00:01:01' would return 61. The time '23:59:59' would return 86399.
<MvFUNCTION NAME = "Time2Seconds" PARAMETERS = "time_str" STANDARDOUTPUTLEVEL = "">
    <MvCOMMENT> Given a string 'hh:mm:ss' returns seconds ((hh * 3600) + (mm * 60) + (ss)) </MvCOMMENT>
    <MvFUNCTIONRETURN VALUE = "{ (gettoken(l.time_str,':',1) * 3600) + (gettoken(l.time_str,':',2) * 60) + gettoken(l.time_str,':',3) }">
</MvFUNCTION>