Okay, so I can never keep track of timezones, etc. I realize there may very well be a utility to do this but I'm not aware of what it is. So I wrote a quick one. It's just a php wrapper to the command:
% TZ=":Asia/Taipei" date
You can find all of the timezones in /usr/share/zoneinfo.
I put this script in my ~/bin, called it timein and made it executable (chmod 755 timein):
#!/usr/bin/php
<?php $city = $_SERVER['argv'][1];
$findresult = `find /usr/share/zoneinfo -iname $city`;
if (strlen($findresult) == 0)
{
print "Sorry, city not found.\n";
exit();
}
$tzarray = split("\n", $findresult);
$tzfile = $tzarray[0];
$tzstring = ":" . str_replace("/usr/share/zoneinfo/", "",$tzfile);
print `TZ="$tzstring" date`;
print "\n";
?>
Usage is simple:
% timein londonIf you wanted to add a city/state that isn't found (but you know of a neighboring file that is), you could probably either copy the file or softlink it in the terminal, e.g.:
Thu Jan 22 05:16:53 GMT 2004
% cd /usr/share/zoneinfo/US share/zoneinfo/US% ls -la (trimmed down) -rw-r--r-- 4 root wheel 130 25 Sep 17:46 Hawaii -rw-r--r-- 3 root wheel 549 25 Sep 17:46 Indiana-Starke -rw-r--r-- 2 root wheel 811 25 Sep 17:46 Michigan share/zoneinfo/US% sudo ln -s Michigan Flint share/zoneinfo/US% ls -la Flint lrwxr-xr-x 1 root wheel 8 21 Jan 23:21 Flint -> Michigan share/zoneinfo/US% timein flint Thu Jan 22 00:21:40 EST 2004Hmm, guess it's a bad time to call my folks...
•
[6,205 views]

