Implementing date/time functions

Since our current project will need to be available in multiple countries we needed to tackle the timezone challenge. However this proved to be really easy by using this great javascript code Momentsjs . It will convert almost anything you throw at it into some readable form. So the solution was to set the server in the UTC timezone and convert it to the users timezone at the client side via Momentjs, This way the date/time is displayed in the timezone set at the client side.

Now to make things even a bit more user friendly, Momentjs is able to convert it localised to “time from x”. So by using this command: moment.utc(utc_date).local().fromNow() , we got a really nice “x time ago” text for the date. In which time is displayed in seconds, hours, days etc.