PHP: How do I convert a server timestamp to the user's timezone?

前端 未结 3 1804
终归单人心
终归单人心 2020-12-16 08:29

I\'m currently storing times using the \'time()\' function in the database. However, it\'s using the timezone of the server, and I\'d like for each user to see the time acco

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 09:11

    UNIX timestamps are by definition in UTC, which means that all conversion should be done just prior to printing out rather than with actual timestamps.

    How to do this however depends on how you're formatting them currently. I believe PHP has built-in timezone handling.

提交回复
热议问题