0

I need to use the CLI to see the time in arbitrary timezones. However, Debian doesn't respond to the recommended solution.

First, I set the local timezone.

dpkg-reconfigure tzdata

Then, I set the system time.

ntpdate pool.ntp.org

I update the hardware clock to reflect the system time.

hwclock --systohc --utc

Now, I follow this post: http://www.linuxquestions.org/questions/programming-9/display-different-timezones-in-command-line-927660/

Which says that I can complete my task using a command such as this: TZ=UTC date && TZ=CDT date && TZ=IST date

However, this is the output I get:

dpkg-reconfigure tzdata && ntpdate pool.ntp.org && hwclock --systohc --utc && TZ=UTC date && TZ=CDT date && TZ=IST date

Current default time zone: 'America/Chicago'
Local time is now:      Tue Apr 16 14:45:29 CDT 2013.
Universal Time is now:  Tue Apr 16 19:45:29 UTC 2013.

16 Apr 19:45:38 ntpdate[12036]: adjust time server 199.102.46.73 offset -0.036668 sec
Tue Apr 16 19:45:39 UTC 2013
Tue Apr 16 19:45:39 CDT 2013
Tue Apr 16 19:45:39 IST 2013
Celada
  • 21,627
  • 4
  • 64
  • 78
  • In the future, please format code and session transcripts in your post so that the lines do not run together. – Celada Apr 16 '13 at 20:22

1 Answers1

1

CDT and IST aren't valid timezone names, so date is defaulting to show you UTC time if you attempt to use those as your timezone.

I'm not sure which timezones you actually meant to use, but try a couple of these. They are valid timezone names.

TZ=Asia/Shanghai date
TZ=America/Vancouver date
TZ=Europe/London date
Celada
  • 21,627
  • 4
  • 64
  • 78
  • How to convert from abbreviation (e.g., CDT) to something that date will accept (e.g., America/Chicago)? How to get the timezone for an arbitrary city? Say, for example, that I want the timezone for Ludhiana, India. That city is not listed under /usr/share/zoneinfo. – Laurence Maddox Apr 16 '13 at 21:12
  • 1
    You cannot convert from short 3-letter timezone abberviations to Olson timezone names because the short abberviations are ambiguous. For example, `America/Montreal` and `Australia/Sydney` both make use of the `EST` abbreviation. As for getting the timezone of an arbitrary city or getting the timezone from a latitude and longitude, this has been asked and answered many times before on SO. See http://stackoverflow.com/questions/4669366/timezone-from-geolocation for just one example among many. – Celada Apr 16 '13 at 21:15
  • Thanks for your help. Those 3-letter abbreviations had me completely stumped. I think this describes the steps required to automate this: http://stackoverflow.com/questions/55901/web-service-current-time-zone-for-a-city. I ended up getting the specific information I needed from wikipedia: "In the tz database it is represented by Asia/Kolkata." My final command is this: `( TZ=America/Chicago date ; TZ=Asia/Kolkata date )`. For more timezones, I would use this: `for K in America/Chicago Asia/Kolkata ; do TZ=$K date ; done` – Laurence Maddox Apr 18 '13 at 21:56