*! version 1.0 11.05.2016

*! Lars Zeigermann

help timestamp

Title

timestamp -- UNIX timestamp and current time/date in both coordinated universal time (UTC) and local time of a user-specified timezone

Syntax

timestamp
[,
timezone(string)
format(string)
quietly]

timestamp_zones
[,
region(string)]

Description

timestamp returns a UNIX timestamp as well as the current time and date in coordinated universal time (UTC) and the local time of a timezone specified by the user. The data is obtained from the application programming interface (API) provided by http://www.convert-unix-time.com/. Running timestamp requires insheetjson and libjson written by Erik Lindsley which are available from SSC. All results are stored in r().

timestamp_zones lists all valid timezones for which timestamp can obtain the local time and date.

Options

timestamp

timezone(string) specifies the timezone for which the local date and time are returned. The default is UTC. Use timestamp_zones to obtain a complete list of all valid timezones.

format(string) specifies the format in which date and time are displayed. Valid formats are default, english, english12, german, rfc1123 and iso8601.

quietly surpresses the output.

timestamp_zones

region(string) selects the region(s) for which all valid timezones are displayed. Valid regions are Africa, America, Antarctica, Arctic, Asia, Atlantic, Australia, Europe, Indian, Pacific and others. Default is all regions.

Example

To obtain a UNIX timestamp and the current time in UTC, we simply type

`"timestamp"'

If we need the local time of a specific timezone rather than UTC, we can first check all valid timezones by typing

`"timestamp_zones"'

or, if we are interested in timezones in America and the Pacific only:

`"timestamp_zones, region(America Pacific)"'

Finally, if we want to obtain the current time for, let's say, Kiritimati (aka Christmas Island) displayed in ISO 8601 format, we specify timestamp as follows:

`"timestamp, timezone(Kiritimati) format(iso8601)"'

Stored results

timestamp stores the following in r():

Macros

r(timezone) timezone

r(timestamp) UNIX timestamp

r(utcDate) UTC date and time

r(localDate) date and time of user-specified timezone

r(dst) yes if daylight saving time, no otherwise

Required SSC packages

Required ssc packages: insheetjson, libjson

Author

Lars Zeigermann, Düsseldorf Institute for Competition Economics (DICE), zeigermann@dice.hhu.de