no script

This is the first part of the It’s About Time series, where we delve into the matter of dealing with time when programming.  If you have any questions, feel free to contact the author at morten@cobraid.dk

Einstein said: “Time is relative”.

That applies to programming as well. Time really depends on how you see and use it.

There are a lot of different ways of measuring time. What we do here at Cobraid is we actually use something called Unix time. In Unix time, time is a number in milliseconds, or seconds from what you might call an epoch. In Unix, the epoch is 1st of January 1970.

Within programing, different measurements can be used for a timestamp (a timestamp is a current event that is recorded by a computer). The one that we use is Unix timestamps in milliseconds.

To the right, is an example of Unix timeline from the epoch, which demonstrated the different dates, the instant time in milliseconds and seconds.

Since Unix Time measurement system was developed in 1970, it is hard to deal with the event that happened before the year. In Unix, it would have to be represented as a negative value. Most software gets around this problem by storing it as a date string instead. Within Cobraid, we use C# where we store it as a long. Luckily in Cobraid, we rarely deal with anything before 1970.

If you would like to explore the subject a bit more, we would recommend checking out Jon Skeet’s tweets or his blog.  He works for Google and was instrumental in creating their entire calendar system. He delves even more into this.