Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I think that in order to answer that question, we should think about the benefits of using UTC to store timestamps.</p> <p>I personally think that the main benefit to that is that the time is always (mostly) guaranteed to be <em>consistent</em>. In other words, whenever the timezone is changed, or DST applied, you don't get back or forth in time. This is especially useful in filesystems, logs and so on. But is it <em>necessary</em> in your application?</p> <p>Think of two things. Firstly, about the time of DST clock shift. Is it likely that your events are going to occur between 2 AM and 3 AM (on the day the clock shift is done)? What should happen then?</p> <p>Secondly, will the application be subject to actual timezone changes? In other words, are you going to fly with it from London to Warsaw, and change your computer timezone appropriately? What should happen in that case?</p> <p>If you answered <em>no</em> to both of those questions, then you're better with the local time. It will make your application simpler. But if you answered <em>yes</em> at least once, then I think you should give it more thinking.</p> <hr> <p>And that was all about the database. The other thing is the time format used internally by the application, and that should depend on what actually you will be doing with that time.</p> <p>You mentioned it exposing the time via an API. Will the application query the database on every request? If you store the time internally as UTC, you will either need to do that or otherwise ensure that on DST/timezone change the cached times will be adjusted/pruned.</p> <p>Will it do anything with the time itself? Like printing <em>the event will occur in 8 hours</em> or suspending itself for circa that time? If yes, then UTC will probably be better. Of course, you need to think of all the forementioned issues.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload