What exactly does the T and Z mean in timestamp?
Asked Answered
F

1

186

I have this timestamp value being return by a web service "2014-09-12T19:34:29Z"

I know that it means timezone, but what exactly does it mean?

And I am trying to mock this web service, so is there a way to generate this timestamp using strftime in python?

Sorry if this is painfully obvious, but Google was not very helpful and neither was the strftime() reference page.

I am currently using this :

x.strftime("%Y-%m-%dT%H:%M:%S%Z")
'2015-03-26T10:58:51'
Foretopsail answered 26/3, 2015 at 15:6 Comment(1)
related: How do I parse an ISO 8601-formatted date?Piercing
G
245

The T doesn't really stand for anything. It is just the separator that the ISO 8601 combined date-time format requires. You can read it as an abbreviation for Time.

The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC).

Both characters are just static letters in the format, which is why they are not documented by the datetime.strftime() method. You could have used Q or M or Monty Python and the method would have returned them unchanged as well; the method only looks for patterns starting with % to replace those with information from the datetime object.

Garretson answered 26/3, 2015 at 15:9 Comment(11)
Thanks, I was able to find a solution via the ISO time to string question #128303 . What is Q or M ?Foretopsail
@roymustang86: Q and M are just random static characters. The point being that they are not %Y or any of the other formatting characters.Garretson
@TomCho: no, Zulu is the NATO phonetic alphabet name for Z, and it is used because the timezone is timezone Zero. See the Wikipedia link I included in the answer: UTC time is also known as "Zulu" time, since "Zulu" is the ICAO spelling alphabet code word for "Z".Garretson
+1 True, I agree with you. It's weird that they don't use the letter J in the military zones. Maybe because of the different pronunciation in idioms like german, or finnish? Anyway thanks for clearing things out.Blubberhead
@TomCho: Z is used for +0000 (GMT at the time) since 1950s (before UTC even existed). As I understand Z is just a letter (you could use a mnemonic Zero and/or pronounce it as Zulu (from the widely used spelling alphabet)Kossuth
"The Z stands for the “zero meridian”, which goes through Greenwich in London, and it is also commonly used in radio communication where it is pronounced “Zulu” (the word for Z in the international radio alphabet). Universal Time (sometimes also called “Zulu Time”) was called Greenwich Mean Time (GMT) before 1972" (from here)Leporine
I was more curt than was necessary. The Cambridge University link is interesting but just a summary, not an authoritative reference. The author could even have misspoken, actually having meant the zero timezone. I rather stick to Wikipedia and leave research and discussion on the finer details to the WP editors.Garretson
Possible to know what is the time zone? For example, I have a time value 2019-04-10T07:19:44+00:00, I only know this is from USA, but not sure USA which zone. Thus, I cant know what is the exact time in Asia. I need to time to check log.Traherne
@PanadolChong: no, that's not a USA timezone. The +00:00 part at the end is the timezone offset, so you have a UTC timestamp.Garretson
@PanadolChong It can be something that happened in the USA, represented via a UTC timestamp, but there is no way of knowing what the local time and thus location of the event was. But if the timestamp is correct in UTC (meaning it happened way before 07:19 in the USA; it was converted to a UTC timestamp / representing the correct time of the event for someone in UTC), the moment/instant in time of this event is still globally unambiguous and clearly defined. Thus, you can still know the exact corresponding local time in any Asian timezone you choose to convert it to.Potherb
I think it's easier to remember that T stands for Time rather than "The T doesn't really stand for anything".Transcurrent

© 2022 - 2024 — McMap. All rights reserved.