Mini-HOWTO: What Time is UTC?
I wanted to know what time it was in UTC, but I forgot my local offset. (It changes twice a year!) I figured I could look in the date
man page, but I came up with an “easier” solution. Simply fudge the time zone and then ask.
0-20:57 djh@noneedto ~$ env TZ=UTC date Tue May 6 03:57:07 UTC 2008
The env
bit is not needed in bash, but it makes tcsh happy.
Update: Mark points out an easier solution:
date -u
Knowing you can set TZ=
is still useful in case you ever need to contemplate an alternate timezone.