Managing date and time in the programming world

Forgetting about the Physics of Time

Wrong data-types choices to store and handle dates

  • Store or send it ‘as is’ (with the timezone UTC +02).
    In the case where you also need to restore the original event source time zone (a user time zone which had been used to create some event), you have to store an additional field or use the specialised data-types like ‘ TIMESTAMP WITH TIMEZONE’ in RDBMS. However, use the latest approach if you really need to know the original source timezone.
  • Convert it to the server or configured timezone if you don’t need the source timezone information. It could be a UNIX timestamp (1483221600), or ISO 2601 string (‘2016–12–31T22:00:00Z’ or ‘2016–12–31T23:00:00+01:00'), LocalDateTime in Java, etc

Handling date/times in UI/UX

  • If you show some time information in your UI without any time zone references in it then use the user system time zone (don’t use your server timezone). The easiest way is to convert them in your ‘front-end’ right before showing on the user’s UI.
  • If you create something worldwide, you have to provide an ability to choose Time Zones in the user settings and/or in your UI views.
    Look at the example from Google :




Software Developer & Architect

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abdulla Abdurakhmanov

Abdulla Abdurakhmanov

Software Developer & Architect

More from Medium

6 Alternatives To Expensive Softwares That Are Just As Good

INFO 350 Final Project

6 things what I really like in Sitecore SXA + useful links

How to Set Goals in Life and Achieve Them: A Complete Guide