Ever wondered what time is it in Los Angeles given your local time? Or maybe you’re just too busy with your late night coding and stumbled upon an epoch time timestamp and quickly want to know what’s the equivalent in Dublin timezone?
I give you a hint, no need to open the holy google, you can just use your old good friend, shell:
Get current time in a different timezone:
$ env TZ=America/Los_Angeles date -d "`date`"
Convert date to a different timezone:
$ env TZ="America/Chicago" date -d "Fri Sep 23 00:00:14 PDT 2011"
Convert epoch time to a date in a specified timezone:
$ env TZ=Europe/Dublin date -d @1316041200
Convert a date to epoch time:
$ date -d "Fri Sep 23 00:00:14 PDT 2011" +%s
/usr/share/zoneinfofor all available timezones you can use when setting
- You can always use
-uswitch to get UTC time