Time
time
returns the local time of the current process server. The value returned is the number of seconds elapsed since midnight.
Syntax
time
Examples
T = time
DTIME=format$("N0:2",int(T/3600))+":"+format$("N0:2",mod(int(T/60),60))+":"+format$("N0:2",mod(T,60))
# These two statements can be replaced by:
DTIME=time$
T=time
Gosub LONG_ROUTINE : # This routine is supposed to last for a long time
T=time-T : # Number of seconds spent
Description
time
returns the local time of the process server as an Integer value equal to 3600hours+60minutes+seconds.
Comments
If you need a time independent from the local zone, use [datetime$](../4gl/datetime$.md). The following code example shows how you can find out the difference between the current time in GMT zone and the current local time. Local Char TS(20)
Local Integer TL, DELTA_TIME
TS=num$(datetime$) : TL=time
# TS has the format "YYYY-MM-DDThh:mm:ss" (hh starts at position 12, mm at position 15, ss at position 18)
# DELTA_TIME will give the difference in seconds between local time and GMT time
DELTA_TIME=TL-3600*val(mid$(TS,12,2))-60*val(mid$(TS,15,2))-val(mid$(TS,18,2))
# Let's bring the value to the closest half hour
DELTA_HOUR=arr(DELTA_TIME/3600,0.5)
Associated errors
No error associated.