2022-08-23
I spent most of today continuing working on my calendar service in Kotlin and also made some changes to the front end, which involved learning a bit about Dates in Javascript.
A Javascript Date object is basically a wrapper around a number representing the milliseconds since 1 January 1970, so it holds information about a date & time.
We can see this if we initialise a new Date:
date = new Date()
date.valueOf()
outputs: 1661370033502
Date doesn't support different time zones - all Dates are in UTC. However, when converted to a string the time is converted to the user's browser time zone:
date.toString()
outputs: Wed Aug 24 2022 20:40:33 GMT+0100 (British Summer Time)
I think this is pretty neat - rendering in the user's time zone is really useful, and this seems like the exact amount of date/time & time zone functionality needed for the browser.