There's still one thing we encounter all to frequently when working with, manipulating or simply extracting data. We can book tickets over our mobile phones, check the news, integrate AI into our websites and determine if one message should be reviewed before another based on sentiment analysis. But in this technological nirvana there is one quiet, dystopian corner... Dates!
For most developers dates are almost a right-of-passage, when you are no longer considered a junior but have morphed into someone more world-wise (and possibly a little more bitter) because you've discovered time zones, or possibly even date formats.
Just to pick on one of these issues lets have a look at date formats. If I write down the date and time of 09/03/2018 10:03 then am I referring to the 9th March or the 3rd September, also is this 10am or 10pm? For internal documents this might not matter when your entire team is located in the same geographical area, but if you're using this in your data or sharing with people in other countries then it matters a lot. I once got a 10 minutes lecture from someone in America about how I'd published a document 3 months in the future.
Some tools don't help either, Microsoft Excel is terrible for adjusting dates and times to local formats when you open and save files. We sometimes see Excel files with a combination of date formats in the same file when people from different countries have worked on different parts of the same file.
So what can be done? Well, there's a few things which you can do which will make life easier for you and everyone else.
Storing dates as Coordinated Universal Time (UTC)
This makes working with dates from devices or systems operating globally a lot easier. Trying to work out the time between two events, distributed globally, when you have to factor in timezone differences and daylight savings is incredibly difficult.
Also, when working with files from others don't assume that they're in UTC or your local time zone. Always double check.
When exchanging dates and times use ISO-8601
Yep, this is such an issue that there is an international standard defining how dates and times should be exchanged, including timezone offsets.
Avoid exchanging dates using tools which can change the format
Tools like Excel are incredibly popular for working with data, but Excel files aren't so good for exchanging data. This is why formats like csv, json, xml and parquet, amongst others, exist.
If you do need to start manipulating date structures or dates with time zones, or even adding time to existing dates then make sure you use good libraries to do this, such as Joda Time if your working with Java based languages.