Dealing with Dates in Web Applications
The basic principles
- Store dates in UTC
- Perform all date calculations in UTC
- Display UTC dates in HTML in the users’ local time zone with JavaScript
- Capture form submissions with a JavaScript event handler and convert the dates entered into UTC before submission to the server
Storing dates in UTC and performing all date calculations in UTC
Really, this part is pretty simple. I’ll let you figure it out on your own. Any details that I could provide here would be very implementation‐specific.
Display UTC dates in HTML in the users’ local time zone with JavaScript
Links for inspiration
Capturing form submissions with a JavaScript event handler and converting the dates entered into UTC before submission to the server
This example form submission handler JavaScript code creates UNIX timestamps for all specified date fields on the form.
Using the JavaScript form submission handler
The form submission handler requires jQuery.