开发者

fact abt ruby time

can anyone tell me why Time.at(0) in ruby gives 1970-01-01 05:30:00 +530 . any s开发者_开发问答pecific reason why it gives this date and time


My crystal ball tells me you are in India. India's time zone is UTC+5:30. The time 0 is the number of seconds since 1970-01-01 00:00:00 UTC, which was 1970-01-01 00:05:30 local time in India.

On my system:

irb(main):001:0> Time.at(0)
=> Thu Jan 01 12:00:00 +1200 1970


That time is the Unix Epoch - from Wikipedia:

Unix time, or POSIX time, is a system for describing points in time, defined as the number of seconds elapsed since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds. It is used widely, not only in Unix-like operating systems, but also in many other computing systems and file formats. It is neither a linear representation of time nor a true representation of UTC (though it is frequently mistaken for both), as it cannot represent standard UTC leap seconds (e.g. December 31, 1998 23:59:60), although otherwise the times it represents are UTC. Unix time may be checked on some Unix systems by typing date +%s on the command line.

Essentially Unix systems count all times as number of seconds from 00:00 UTC on 1970-01-01.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜