Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to read a timestamp?

Tags:

timestamp

time

This is an incredibly dumb question, but I'm struggling to understand.

I have a timestamp:

 2017-02-03T06:16:59.094-08:00

When was this timestamp in UTC? Was it 2017-02-03 14:16:59.094 or 2017-02-02 06:16:59.094?

In other words, does the -08:00 at the end mean that this is a local timestamp and that the timezone is 8 hours behind UTC? (2017-02-03 14:16:59.094)

Or does it just mean that the timestamp is UTC, but that it was recorded in a timezone 8 hours behind UTC?

like image 427
Richard Avatar asked Jan 30 '18 16:01

Richard


1 Answers

If you want UTC time, then add 8 hours. The time you see is in local time.

Here is how it works:

Time offsets from UTC The offset from UTC is appended to the time in the same way that 'Z' was above, in the form ±[hh]:[mm], ±[hh][mm], or ±[hh]. So if the time being described is one hour ahead of UTC, such as the time in Berlin during the winter, the zone designator would be "+01:00", "+0100", or simply "+01". To represent a time behind UTC the offset is negative. For example, the time in New York during standard (not daylight saving) hours is UTC−05:00 and the zone designator would then be "−05:00", "−0500", or simply "−05". For other time offsets see List of UTC time offsets. To represent a negative offset, ISO 8601 specifies using either a hyphen–minus or a minus sign character. If the interchange character set is limited and does not have a minus sign character, then the hyphen–minus should be used. ASCII does not have a minus sign, so its hyphen–minus character (code is 45 decimal or 2D hexadecimal) would be used. If the character set has a minus sign, then that character should be used. Unicode has a minus sign, and its character code is U+2212 (2212 hexadecimal); the HTML character entity invocation is −.

The following times all refer to the same moment: "18:30Z", "22:30+04", "1130−0700", and "15:00−03:30". Nautical time zone letters are not used with the exception of Z. To calculate UTC time one has to subtract the offset from the local time, e.g. for "15:00−03:30" do 15:00 − (−03:30) to get 18:30 UTC.

An offset of zero, in addition to having the special representation "Z", can also be stated numerically as "+00:00", "+0000", or "+00". However, it is not permitted to state it numerically with a negative sign, as "−00:00", "−0000", or "−00". The section dictating sign usage (section 3.4.2 in the 2004 edition of the standard) states that a plus sign must be used for a positive or zero value, and a minus sign for a negative value. Contrary to this rule, RFC 3339, which is otherwise a profile of ISO 8601, permits the use of "-00", with the same denotation as "+00" but a differing connotation.[29]

ISO 8601 permits the hyphen (-) to be used as the minus (−) character when the character set is limited.[30] In contrast, RFC 3339 explicitly requires the hyphen (-) symbol to represent negative offsets and does not allow for use of the minus (−) symbol.[31]

https://en.wikipedia.org/wiki/ISO_8601

like image 57
David M Avatar answered Oct 08 '22 04:10

David M