# getdate

Gets current date.

    getdate <strvar> [<format> [<timezone>]]

## Remarks

Returns the current date in the string variable <strvar>, with the default format "YYYY-MM-DD". The user can specify the format same as strftime. And also, the default format equals "%Y-%m-%d" at the <format> argument.

The behavior of the getdate command specified with the format equals the gettime 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 -255 characters-.
2 | Error. <format> is invalid.

## Example

    ;Stores the current date to "datestr" variable with YYYY-MM-DD format.
    getdate datestr

    ;Stores the current date with the user format to "logfile" variable.
    ;The format is log-YYYYMMDD-HHMMSS.txt.
    getdate logfile "log-%Y%m%d-%H%M%S.txt"

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

    ;To retrieve Today's date.
    gettime s "|%d|%#d|"    ; |07|7| (Today is 7th).
    gettime s "|%d|%#d|"    ; |25|25| (Today is 25th).

## See also

- gettime
- strftime (MSDN Library)