CurrentTime$ ( )
Parameters
| None. |
Description
|
Returns the current time of day as a string. The format is fixed: hours, minutes and seconds on the 24-hour clock, colon separated and zero padded - "14:31:57". It reads the machine's local time, so it matches the clock the player sees. Use it for anything a person will read: a timestamp in a debug log, the time on a save slot, a clock in the corner of a level editor, or a day-night cycle driven by the real time of day. Together with CurrentDate it gives you a full timestamp. The fixed width makes it easy to pick apart - the hour is always the first two characters - so building a "good morning" greeting or a real-time-of-day lighting tint takes a single Left call. It only ticks once a second and jumps backwards at midnight, so it is no use for measuring how long something took. Use MilliSecs for that. See also: CurrentDate, MilliSecs, Str. |
Example
; CurrentTime Example ; ------------------- ; CurrentTime$ returns the system clock as a string ; in the 24-hour format HH:MM:SS, e.g. "14:31:57". now$=CurrentTime$() Print "The time is "+now$ Print "" ; The fixed format makes the parts easy to slice out Print "Hour: "+Left$(now$,2) Print "Minutes: "+Mid$(now$,4,2) Print "Seconds: "+Right$(now$,2) Print "" ; Use the hour as a number to pick a title-screen greeting hour=Left$(now$,2) If hour<12 Then Print "Good morning, player!" ElseIf hour<18 Then Print "Good afternoon, player!" Else Print "Good evening, player!" EndIf Print "" Print "Press any key to close the example" WaitKey End
Index