LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-07-2006, 03:58 AM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
world time on console


I'm trying to get different countries time on my console of Fedora 5. I do "env TZ=russia date" or "env TZ=singapore date" and it gives me the same time in both the cases; eg. "Mon Nov 6 09:47:37 russia 2006". My localtime is correct and I'm not sync'ing with any NTPD. Looks like whatever world-time I choose is always +10 GMT/UTC. My local time is in AEST (Australian Eastern Standard Time).
 
Old 11-07-2006, 04:22 AM   #2
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
I have not unravelled all of the mysteries of how linux deals with time zones, but I believe the date command is taking its time zone info from /etc/localtime independent of the value of TZ. You can find the time in a different zone using the zdump command with the time zone file as its argument. For example, to find out what time it is in Denver, type:

zdump /usr/share/zoneinfo/America/Denver

If you are going to do this a lot, this is something that would easily lend itself to simple scripting to save yourself some typing.

(I am on a public winXP computer and am doing this from memory, so I may have made an error in the path in my example. If so, adjust accordingly.)
 
Old 11-07-2006, 06:47 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
Quote:
Originally Posted by blackhole54
I have not unravelled all of the mysteries of how linux deals with time zones, but I believe the date command is taking its time zone info from /etc/localtime independent of the value of TZ. You can find the time in a different zone using the zdump command with the time zone file as its argument. For example, to find out what time it is in Denver, type:

zdump /usr/share/zoneinfo/America/Denver
blackhole54 - I didn't know about the zdump command - thanks a lot, I had wondered if there was a mechanism to do this. It turns out you can omit the /usr/share/zoneinfo/ if you like.

Quote:
Originally Posted by blackhole54
If you are going to do this a lot, this is something that would easily lend itself to simple scripting to save yourself some typing.

(I am on a public winXP computer and am doing this from memory, so I may have made an error in the path in my example. If so, adjust accordingly.)
Your memory is fine.

noir911, you could define an alias and put it in your .bashrc. I assume there is a some standard list of locations for which you wish to show the time. For example:
Code:
$ alias show_my_times='zdump Singapore Europe/Moscow Europe/London US/Eastern'
$ show_my_times
Singapore      Tue Nov  7 20:42:49 2006 SGT
Europe/Moscow  Tue Nov  7 15:42:49 2006 MSK
Europe/London  Tue Nov  7 12:42:49 2006 GMT
US/Eastern     Tue Nov  7 07:42:49 2006 EST
To find the names of the timezones, you can do something like this:
Code:
$ find /usr/share/zoneinfo -type f |grep -i singapore |xargs zdump |cut -c21-
Asia/Singapore        Tue Nov  7 20:45:05 2006 SGT
posix/Asia/Singapore  Tue Nov  7 20:45:05 2006 SGT
posix/Singapore       Tue Nov  7 20:45:05 2006 SGT
right/Asia/Singapore  Tue Nov  7 20:44:42 2006 SGT
right/Singapore       Tue Nov  7 20:44:42 2006 SGT
Singapore             Tue Nov  7 20:45:05 2006 SGT
As you can see there are many different definitions for Singapore. Just choose the one you want.
 
Old 11-07-2006, 09:43 AM   #4
blackhole54
Senior Member
 
Registered: Mar 2006
Posts: 1,896

Rep: Reputation: 61
Quote:
Originally Posted by matthewg42
blackhole54 - I didn't know about the zdump command - thanks a lot, I had wondered if there was a mechanism to do this. It turns out you can omit the /usr/share/zoneinfo/ if you like.
Then we both learned something. I wasn't aware you could drop the first part of the path or that you could give multiple arguments. I had also forgotten that zdump is in /usr/sbin which means it probably won't be in the PATH of a normal user. However, no priviledge is required to actually run it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
World Time Desktop Background mrajp Linux - Software 1 10-22-2004 04:36 PM
How to find out idle time at console? redss Linux - General 1 04-26-2004 10:23 PM
Searching for clock-synchro to world time server Schmurff Linux - Software 1 03-09-2004 10:26 AM
how much time are you on the console? gui10 Linux - General 14 04-17-2002 12:28 AM
Is it possible to have only 1 user signed in at a time or only allow console Sign Ins adamrau Linux - Security 5 11-19-2001 02:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration