Formatting an SQL timestamp with PHP

后端 未结 6 547
無奈伤痛
無奈伤痛 2020-12-01 16:15

I have a mySQL database with a timestamp field. It currently only has one entry while I\'m testing, it is

2010-02-20 13:14:09

I am pulling

6条回答
  •  佛祖请我去吃肉
    2020-12-01 16:34

    EDIT: After checking, it appears that MySQL returns a timestamp as a string to PHP, so this answer was bogus :)

    Anyway, the reason you get a date in 1969 is probably that you're converting a zero unix time from UTC to localtime. The unix time is the number of seconds since 1970. So a value of 0 means 1970. You probaby live in a timezone with a negative offset, like GMT-6, which ends up being 31-12-69.

提交回复
热议问题