Optimal way to store and pass a date to Javascript

Posted by user1493115 on Stack Overflow See other posts from Stack Overflow or by user1493115
Published on 2012-06-30T14:37:09Z Indexed on 2012/06/30 15:16 UTC
Read the original article Hit count: 163

Filed under:
|
|
|
|

I need to store a date-time value in MySQL and subsequently display it on a webpage. Due to its flexibility I usually chose to store a Unix timestamp in the database and convert it with PHP's date() to the desired format.

This time however I would like to use MySQL's datetime field (mostly due to 2038) and apply the browser's timezone (hence I cannot simply format it on the server and pass the string to the client).

I thought of storing the date as UTC datetime in the database and send it as well-defined format to the client, where it will be further processed. Here I would like to avoid a Unix timestamp but everything else might add additional overhead in processing.

Is there any best practice as far as date processing is concerned in a MySQL, PHP, JQuery environment?

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript