2016-06-14 21:55:04 +00:00
|
|
|
utc: convert times to UTC
|
|
|
|
|
2016-06-16 05:05:58 +00:00
|
|
|
Usage: utc [-f format] [-o format] [-q] [-t] [-u] [-z zone] [time(s)...]
|
|
|
|
utc -h | utc help
|
|
|
|
|
|
|
|
|
2016-06-14 21:55:04 +00:00
|
|
|
utc converts times to UTC. If no arguments are provided, prints the
|
2016-06-16 01:24:41 +00:00
|
|
|
current time in UTC. If the only argument provided is "-", utc reads
|
|
|
|
newline-separated timestamps from standard input. If the argument is
|
|
|
|
"help", it will print an extended help message with examples. If both
|
|
|
|
the input and output timezones are the same (e.g., the local time zone
|
|
|
|
is UTC), a warning message will be printed on standard error. This can
|
|
|
|
be suppressed with the -q option.
|
|
|
|
|
2016-06-14 21:55:04 +00:00
|
|
|
Flags:
|
|
|
|
|
2016-06-14 22:22:38 +00:00
|
|
|
-f format Go timestamp format for input times. See the Go docs
|
2016-06-14 21:55:04 +00:00
|
|
|
(e.g. https://golang.org/pkg/time/#pkg-constants)
|
|
|
|
for an explanation of this format.
|
2016-06-14 22:22:38 +00:00
|
|
|
|
|
|
|
Default value: 2006-01-02 15:04
|
|
|
|
|
2016-06-14 23:42:33 +00:00
|
|
|
-h Print this help message.
|
2016-06-14 22:22:38 +00:00
|
|
|
|
2016-06-16 05:05:58 +00:00
|
|
|
-o format Go timestamp format for outputting times.
|
|
|
|
It uses the same format as the '-f' argument.
|
2016-06-16 01:24:41 +00:00
|
|
|
|
|
|
|
Default value: 2006-01-02 15:04 MST
|
2016-06-14 22:22:38 +00:00
|
|
|
|
2016-06-14 23:42:33 +00:00
|
|
|
-q Suppress the timezone check warning message.
|
|
|
|
|
2016-06-16 05:05:58 +00:00
|
|
|
-t Input times are Unix timestamps. Use with
|
|
|
|
-u to convert the timestamp to the timezone
|
|
|
|
specified by the -z option (which defaults
|
|
|
|
to Local).
|
|
|
|
|
|
|
|
-u Timestamps are in UTC format and should be
|
|
|
|
converted to the timezone specified by the
|
|
|
|
-z argument (which defaults to 'Local'). Note
|
|
|
|
that this isn't particularly useful with
|
|
|
|
no arguments.
|
2016-06-14 22:22:38 +00:00
|
|
|
|
2016-06-14 21:55:04 +00:00
|
|
|
-z zone Text form of the time zone; this can be in short
|
2016-06-16 05:05:58 +00:00
|
|
|
time zone abbreviation (e.g. MST) or a
|
|
|
|
location (e.g. America/Los_Angeles). This
|
|
|
|
has no effect when printing the current
|
|
|
|
time.
|
2016-06-14 22:22:38 +00:00
|
|
|
|
|
|
|
Default value: Local
|
2016-06-14 21:55:04 +00:00
|
|
|
|
|
|
|
Examples (note that the examples are done in the America/Los_Angeles /
|
|
|
|
PST8PDT time zone):
|
|
|
|
|
|
|
|
+ Getting the current time in UTC:
|
|
|
|
$ utc
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 14:30 PDT = 2016-06-14 21:30 UTC
|
2016-06-14 21:55:04 +00:00
|
|
|
+ Converting a local timestamp to UTC:
|
|
|
|
$ utc '2016-06-14 21:30'
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 21:30 PDT = 2016-06-15 04:30 UTC
|
2016-06-14 21:55:04 +00:00
|
|
|
+ Converting a local EST timestamp to UTC (on a machine set to
|
|
|
|
PST8PDT):
|
|
|
|
$ utc -z EST '2016-06-14 21:30'
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 21:30 EST = 2016-06-15 02:30 UTC
|
2016-06-14 21:55:04 +00:00
|
|
|
+ Converting timestamps in the form '14-06-2016 3:04PM':
|
|
|
|
$ utc -f '02-01-2006 3:04PM' '14-06-2016 9:30PM'
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 21:30 PDT = 2016-06-15 04:30 UTC
|
2016-06-14 21:55:04 +00:00
|
|
|
+ Converting timestamps from standard input:
|
|
|
|
$ printf "2016-06-14 14:42\n2016-06-13 11:01" | utc -
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 14:42 PDT = 2016-06-14 21:42 UTC
|
|
|
|
2016-06-13 11:01 PDT = 2016-06-13 18:01 UTC
|
2016-06-14 21:55:04 +00:00
|
|
|
+ Converting a UTC timestamp to the local time zone:
|
|
|
|
$ utc -u '2016-06-14 21:30'
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 21:30 UTC = 2016-06-14 14:30 PDT
|
2016-06-14 21:55:04 +00:00
|
|
|
+ Converting a UTC timestamp to EST (on a machine set to
|
|
|
|
PST8PDT):
|
|
|
|
$ utc -u -z EST '2016-06-14 21:30'
|
2016-06-16 01:24:41 +00:00
|
|
|
2016-06-14 21:30 UTC = 2016-06-14 16:30 EST
|
2016-06-14 22:22:38 +00:00
|
|
|
+ Using a different output format:
|
2016-06-16 01:24:41 +00:00
|
|
|
$ utc -o '2006-01-02T15:03:04-0700' '2016-06-14 21:30'
|
|
|
|
2016-06-14T21:09:30-0700 = 2016-06-15T04:04:30+0000
|
2016-06-16 05:05:58 +00:00
|
|
|
+ Converting a Unix timestamp to a UTC time:
|
|
|
|
$ utc -t 1466052938
|
|
|
|
2016-06-15 21:55 PDT = 2016-06-16 04:55 UTC
|
|
|
|
+ Converting a Unix timestamp to local time:
|
|
|
|
$ utc -t -u 1466052938
|
|
|
|
2016-06-16 04:55 UTC = 2016-06-15 21:55 PDT
|
|
|
|
+ Converting a Unix timestamp to EST:
|
|
|
|
$ utc -t -u -z EST 1466052938
|
|
|
|
2016-06-16 04:55 UTC = 2016-06-15 23:55 EST
|
2016-06-14 23:42:33 +00:00
|
|
|
+ Example of the warning message when running utc on a machine
|
|
|
|
where the local time zone is UTC:
|
|
|
|
$ utc
|
|
|
|
|
|
|
|
==================================================================
|
|
|
|
Note: both input and output timezone offsets are the same --- this
|
|
|
|
program may not do what you expect it to.
|
|
|
|
|
|
|
|
(Converting from UTC (offset +0000) to UTC (offset +0000).)
|
|
|
|
==================================================================
|
|
|
|
2016-06-14 23:44 = 2016-06-14 23:44
|
|
|
|
+ Example of the warning message when running utc on a machine
|
|
|
|
where the local time zone is GMT:
|
|
|
|
$ utc
|
|
|
|
|
|
|
|
==================================================================
|
|
|
|
Note: both input and output timezone offsets are the same --- this
|
|
|
|
program may not do what you expect it to.
|
|
|
|
|
|
|
|
(Converting from GMT (offset +0000) to UTC (offset +0000).)
|
|
|
|
==================================================================
|
|
|
|
2016-06-14 23:46 = 2016-06-14 23:46
|
2016-06-16 01:24:41 +00:00
|
|
|
|