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

Me, elsewhere

Miscellaneous public code

A PHP API client for Reddit

I don't tweet much

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

Perfect is the enemy of good enough.

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

📰 Caveat with Vantec SATA/IDE to USB 2.0 Adapter and Macrium software

📰 Jay Niffley, Man of Mystery

📰 Compiling Doxygen on FreeBSD without LaTeX and Ghostscript

📰 Introducing Snuze, a PHP client for the Reddit API

📰 jisusaiche: Java's installer telemetry

📰 BIND client log error "query_find: query_getdb failed"

📰 Resolving "The lang/perl5.24 port has been deleted: Has expired" portmaster error

📰 Armagaddon2 interim fix for Firefox 56 and other old versions

📰 Strange DNS queries: qname "miep", qtype ANY

📰 Undeliverable as addressed: A massive broken spam campaign?

📰 Using WITH_META_MODE and ccache for FreeBSD build boosts

📰 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

▲ Back to top | Permalink to this page