Time zone conversion using GNU date

From Brandonhutchinson.com

(Difference between revisions)
Jump to: navigation, search
(New page: What is the current time in the system-wide timezone? (I don't have the TZ environment variable set, so I'm using the system-wide timezone) $ '''date''' Fri Nov 9 14:06:15 CST 2007 Wha...)
Line 1: Line 1:
 +
There are excellent Web-based time zone converters[http://www.timeanddate.com/worldclock/converter.html], but it is easy to do on a UNIX system using ''zdump'' and ''GNU date''.
 +
 +
These examples were performed on a Ubuntu system.
 +
What is the current time in the system-wide timezone? (I don't have the TZ environment variable set, so I'm using the system-wide timezone)
What is the current time in the system-wide timezone? (I don't have the TZ environment variable set, so I'm using the system-wide timezone)
$ '''date'''
$ '''date'''
Line 14: Line 18:
$ '''TZ=Australia/Sydney date -d '11/12/2007 21:00 CST''''
$ '''TZ=Australia/Sydney date -d '11/12/2007 21:00 CST''''
Tue Nov 13 14:00:00 EST 2007
Tue Nov 13 14:00:00 EST 2007
 +
 +
Which time zones may I choose from?
 +
$ '''$ find /usr/share/zoneinfo -type f'''

Revision as of 20:24, 9 November 2007

There are excellent Web-based time zone converters[1], but it is easy to do on a UNIX system using zdump and GNU date.

These examples were performed on a Ubuntu system.

What is the current time in the system-wide timezone? (I don't have the TZ environment variable set, so I'm using the system-wide timezone)

$ date
Fri Nov  9 14:06:15 CST 2007

What is the current time in Sydney, Australia?

$ TZ=Australia/Sydney date
Sat Nov 10 07:07:38 EST 2007

What is the time in Sydney, Australia, when it's 9 pm CST today? (If you don't specify the current date after -d, it seems to always choose tomorrow's date)

$ TZ=Australia/Sydney date -d '11/9/2007 21:00 CST'
Sat Nov 10 14:00:00 EST 2007

What is the time in Sydney, Australia, when it's 9 pm CST on 2007/11/12?

$ TZ=Australia/Sydney date -d '11/12/2007 21:00 CST'
Tue Nov 13 14:00:00 EST 2007

Which time zones may I choose from?

$ $ find /usr/share/zoneinfo -type f
Personal tools