PHP & MySQL: Converting Stored TIMESTAMP into User's Local Timezone

前端 未结 4 746
遇见更好的自我
遇见更好的自我 2020-12-09 11:12

So I have a site with a comments feature where the timestamp of the comment is stored in a MySQL database. From what I understand, the timestamp is converted to UTC when sto

4条回答
  •  有刺的猬
    2020-12-09 11:49

    There is no reliable way to get the user's timezone. Timezone information is not sent in HTTP headers. The best that you could do is either:

    1. Match the IP address againsta geographic database -or-
    2. Use Javascript to get the time set on the user's computer and either send that to the server (AJAX) or make the time string on the client.

提交回复
热议问题