(new Soapbox())->shout(array_map('strtoupper', $opinions)); //Shaun's blog

Me, elsewhere

Miscellaneous public code

I don't tweet much

XMPP chat
(Pidgin, Miranda, Swift, etc.)

Using TZ and "date" to find the current date and time anywhere on Earth

Posted December 14, 2015 by shaun

From a Linux terminal, if you need to find out what time it is in a different time zone or another country, you can use the date command. Just override the TZ environment variable when you run date:

[user@host ~]$ date
Mon Dec 14 22:10:59 CST 2015

[user@host ~]$ TZ=Poland date
Tue Dec 15 05:11:03 CET 2015

[user@host ~]$ TZ=Japan date
Tue Dec 15 13:11:07 JST 2015

[user@host ~]$ TZ=Australia/Melbourne date
Tue Dec 15 15:12:36 AEDT 2015

[user@host ~]$ TZ=Australia/Perth date
Tue Dec 15 12:12:41 AWST 2015

The full list of supported time zones will be somewhere on your filesystem; on many distributions, they're located at /usr/share/zoneinfo/. If you aren't sure where to find them, Wikipedia has a tz database that's mostly accurate.

Because some of the time zone names are cumbersome to remember and type, consider using aliases if you need to reference international times frequently. You can add commands like this to your .bash_profile or .bashrc,

alias nyctime='TZ=America/New_York date'
alias hktime='TZ=Asia/Hong_Kong date'
alias jtime='TZ=Japan date'

Now you can just run the aliases from your shell:

[user@host ~]$ date
Mon Dec 14 22:16:08 CST 2015

[user@host ~]$ jtime
Tue Dec 15 13:16:10 JST 2015

[user@host ~]$ nyctime
Mon Dec 14 23:16:14 CST 2015

This also works on FreeBSD, but the time zone naming scheme is different for many countries. For example, Japanese time is referenced on FreeBSD using TZ=Asia/Tokyo rather than TZ=Japan. Explore the contents of /usr/share/zoneinfo/ to find the zone you're looking for.

Recent articles

📰 Resolving subversion error E000013: Unable to create pristine install stream

📰 Enhancements to SmokePing's AnotherDNS probe

📰 Generating vanity DNSSEC key tags

📰 DDoS involving forged packets from

📰 Website integrity monitoring through version control

📰 SpamAssassin 3.4.2 fixes security problems, adds HashBL and phishing plugins

📰 Bug or turf war? ICQ via Pidgin now fails with "startOSCARSession: Request Timeout"

📰 🎂

📰 SFSQuery, a PHP class to query the StopForumSpam API and DNSBL

📰 Resolving portmaster error "pkg-static: automake-1.16.1 conflicts with automake-wrapper-20131203"

📰 Resolving LibreNMS error "RuntimeException: The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths"

📰 Fast, but not so accurate (yet)

📰 autodiscover.xml as an Indicator of Attack

📰 Blocking Facebook's Tracking and Surveillance: A Comprehensive Approach

📰 Let's Encrypt Readies for Certificate Transparency with Embedded SCTs

▲ Back to top | Permalink to this page