dannyman.toldme.com


FreeBSD, Linux, Mac OS X, Technical

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.

(Thanks, Saul and Dave for improving my knowledge.)

Read More

Next:
Previous:
Categories: FreeBSD, Linux, Mac OS X, Technical
Possibly-Related Posts

Responses

May 6th, 2008

dbt

env TZ= date works just as well, without needing to be undone…

May 6th, 2008

dannyman

(Thanks, dbt . . . this post just got a lot shorter. ;)

July 9th, 2008

mark

How about ‘date -u’?

Comment

Leave a comment . . .

Tiny Print:

  1. For private messages, e-mail me: dannyman@toldme.com.
  2. You must provide an e-mail address.
  3. You can use a bogus e-mail address, but I like to know who you are.
  4. I will not spam you. I will not publish or share your e-mail address.
  5. First-time commenters will be held for review.
  6. You can use these HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>