Frage

Why 7/18/2013 11:33 is different in GMT timezone and in my local Time Zone (Asia/kolkata)? As Unix time-stamp are the ticks being calculated since epoch time 1/1/1970 00:00:00 GMT so i know that there the epoch time had occurred at different interval in different timezone but still. the number of second elapsed should have been same

For example if I(+5:30 GMT) and My friend(+5:00 GMT) starts counting the ticks from 00:00 Hrs respectively so at 18:00 Hrs in both timezone number of ticks should be same. So why same thing is not true with the Unix time-stamp.

Need to Understand the concept fully.

War es hilfreich?

Lösung

For example if I(+5:30 GMT) and My friend(+5:00 GMT) starts counting the ticks from 00:00 Hrs respectively so at 18:00 Hrs in both timezone number of ticks should be same.

No, because both of you start counting from 00:00 UTC. That's the definition. So for you, that will mean the number of ticks since 18:30, and for your friend it will mean the number of ticks since 19:00.

The idea is that a single instant in time has the same timestamp value everywhere. So if I were calling you now (and ignoring phone delays) we could both agree that "now" is a Unix timestamp of 1374130418. You may have a different local time to me, but we can express "now" in a common format.

See the "core concepts" part of the Noda Time user guide for more discussion of local time vs "global" time.

Andere Tipps

When your system is configured correctly, the unix time stamp shows you the ticks since 1.1.1970 in Greenwich. So when you an your friend read the timestamp at 18:00 at your local time, you do it with 30 minutes delay and therefore have 1800 seconds difference.

If this isn't the case, one or both of the system clocks isn't set correctly to use GMT as base. Usually this kind of problem doesn't have negative impact as long as you're just working on one system or all systems are set incorrectly the same way.

The Unix time is given as seconds since the epoch: the number of seconds (not counting leap seconds) that have passed since 00:00:00 Coordinated Universal Time (UTC), or Thursday, January 1st, 1970,

The GNU date command has some very nice features that allow you to translate between different time formats. These are explained very nicely in man date so I will only give you some examples here:

### "Normal" format
$ date
Thu Jun 12 11:44:23 CEST 2014
### Unix time
$ date +%s
1402566271

To convert, you can give date a specific date using the -d flag. However, to get a Unix date, this needs to be a full date. You can't convert 3:00PM to Unix time since Unix time refers to an entire date (year,month,day,time). So, for example, to get the Unix date for the 12th of September 1987, you would do:

$ date -d "3 PM 12 September 1987" +%s
558450000

And to convert that back to a "normal" date:

$ date -d "@558450000" 
Sat Sep 12 15:00:00 CEST 1987
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top