Hello, it’s 20150130T2015+0100 and i will teach you to understand what i just wrote.
##Motivation
Within this international community it’s a rather common task to communicate time and date of certain events, e.g. to schedule games. (If you’re part of the nova league I highly recommend you proceed reading.)
Problem: We all have different timezones and formats. So what can we say about “15/12/03 7pm”? Well, not much, but that’s 7pm somewhere on earth maybe this year’s December 3rd or December 12th 2003.
Solution: Standards. Namely ISO 8601 and RFC 3339 (you don’t need to remember those names, there will be no test.)
With very little effort it’s possible to avoid all ambiguities.
##Calendar dates
Easy things first: To refer to an unambiguous date all you need is the following format:
YYYY-MM-DD
YYYY is the year using 4 digits,
MM is the month using 2 digits,
DD is the day using 2 digits.
So today it’s 2015-01-30. Easy, huh?
However, be careful of our first banana skin: I’m in Europe, however, would I be located in Japan it would be 2015-01-31 right now.
The reason for that confusion is the worst fun since meeting on the internet: timezones. (You probably heard about them.)
##Time and timezones
If you take a quick look at your calendar and clock you can probably determine your localtime. That’s the time for wherever you are. Telling other people about that time is great, however, without the information about what timezone you’re talking, they won’t really be able to relate to that.
You might already know, that your timezone is called say Pacific Standard Time (PST). So why not tell them “7pm PST”? Well, the reason is a simple one: How the Richard F. Heck should anyone besides you know what PST is or how to translate that to their localtime? And does someone really need to know that EST is Eastern Standard Time which refers to the east of the U.S. and has nothing to do with EEST which in turn is Eastern European Summer Time?
The slightly experienced time communicator might say “well, easy: use UTC”. Good thinking, but that’s only one way.
Others might think: “Could you please stop to throw around with random acronyms?” I promise this was the last one except for that one Wikipedia will use.
Coordinated Universal Time (French: temps universel coordonné), abbreviated as UTC, is the primary time standard by which the world regulates clocks and time. It is one of several closely related successors to Greenwich Mean Time (GMT). For most purposes, UTC is considered interchangeable with GMT, but GMT is no longer precisely defined by the scientific community.
— Coordinated Universal Time - Wikipedia
If you prefer to use tools to translate between timezones, you could declare anything in UTC (and mark that) and stop reading here. But then I don’t want to see any more timezone acronyms I don’t understand, deal?
###Offsets
An important thing about timezones: They are defined as offset to UTC. Japan (Japan Standard Time) would be UTC+9.
So the math for translating Japanese times to UTC is pretty easy: time – 9 hours.
19:00 in Japan would be 10:00 in UTC, yay.
You can find out what’s your offset on the internet.
Now you can easily translate between localtime and UTC:
UTC time = localtime – offset
localtime = UTC time + offset
Well, of course translating between any two offsets is not that much hard either:
targettime = sourcetime – sourceoffset + targetoffset
So, let’s say we’re in Ohio (UTC–5) and it’s 10:30. We want to translate to Portugal (UTC–1):
targettime = 10:30 – (–5) + (–1)
targettime = 10:30 + 5 – 1
targettime = 10:30 + 4
= 14:30
###Daylight saving
Haven’t I told you there’ll be banana skins? You might ask yourself: “Why should I have only one timezone, when I could have two or something?”
I guess, you don’t ask that yourself, however, if you did, I would have such good news for you:
You might have noticed that sometimes (as in twice a year) the clock shifts for one hour (back and forth). You’re guessing right, that does indeed change your offset! So if that’s true for your location, you’ll have the fun of remembering two offsets and when they are applicable. You can determine whether you have Daylight Saving Times and when the shifts are on the former posted website.
Yep, there are those lucky guys, who miss that fun, e.g. those in Japan.
###Format
Since we’re now able to translate between timezones without using UTC directly, all we need is a fancy way to write that down. (Standards, remember?)
hh¹:mm¹±hh²[:mm²]
hh¹: hours of time in 24h-format (2 digits)
mm¹: minutes of time (2 digits)
hh²: hours of offset (2 digits)
mm²: minutes of offset (2 digits, optional)
So our Ohio-Portugal example would be noted with 10:30–05 and 14:30–01 respectively. Note: Both times are identical, as is 15:30+00.
By the way +00 is the offset of UTC itself (since UTC+0 = UTC). Since it’s often used there is also a very hip way to save time: 15:30Z (the Z denotes +00:00).
And yes, the minutes part of the offset is also used, e.g. Venezuelan Standard Time is UTC–04:30.
##Bonus
Since you’re probably the only one to have come this far and I promised to explain what those numbers in the beginning mean, I’ll update it for the current time and explain:
20150130T2147+0100
First you need to spot the T, which denotes a calendar date left oft it and a time to the right.
Since the number of digits and order of information is preset, it’s actually optional to use ‘-’ and ‘:’ as isolators.
How long it took me to write this down and whether you had luch or dinner at that time is left as an exercise for the reader.