# gettime

Gets current time.

    gettime <strvar> [<format> [<timezone>]]

## Remarks

Returns the current time in the string variable <strvar>, with the default format "HH:MM:SS". The user can specify the format same as strftime. And also, the default format equals "%H:%M:%S" at the <format> argument.

The behavior of the gettime command specified with the format equals the getdate command specified with the same format.
When the <timezone> argument is specified as a timezone string, the timestamp is generated by using the timezone. When the <timezone> argument is not specified, the timestamp is treated as the localtime.

This command returns one of the following values in the system variable "result":

Value | Meaning
--- | ---
0 | Normal success. <strvar> is stored.
1 | Error. <strvar> is not stored because a length of the generated string exceeds the upper limit -511 characters-.
2 | Error. <format> is invalid.

## Example

    ;Stores the current time to "timestr" variable with HH:MM:SS format.
    gettime timestr

    ;Stores the current date with the user format to "logfile" variable.
    ;The format is log-YYYYMMDD-HHMMSS.txt.
    gettime logfile "log-%Y%m%d-%H%M%S.txt"
    changedir 'C:\Test'
    logopen logfile 0 0
    logwrite 'test data'
    logclose

    ;To generate a GMT/UTC time stamp
    tz="GMT"
    gettime s "%Y/%m/%d %H:%M:%S" tz
    messagebox s tz

## See also

- getdate
- strftime (MSDN Library)