1

strtotime is giving me the wrong time zone of (+0730) vs the correct timezone of (+0800).

I have my date time stored on MySQL in a datetime field. The data that is stored in that field is

2016-08-02 09:30:00

I am getting my PHP scripts to send a JSON output of that value to a Javascript.

Console.log of PHP's output (without strtotime) {date: "2016-08-02 09:30:00", timezone_type: 2, timezone: "SGT"}

Console.log of PHP's strtotome output 1470103200 which works out to Tue Aug 02 2016 10:00:00 GMT+0800 (SGT), and on some of the HTML outputs, i'm getting Tue Aug 02 2016 09:30:00 GMT+0730

My server's date +%Z output is SGT.

MySQL's SELECT @@global.time_zone, @@session.time_zone; is SYSTEM

Any idea why PHP's strtotime is giving me time in the wrong timezone?

Deepak Adhikari
  • 419
  • 2
  • 4
Ong Pe Hon
  • 305
  • 3
  • 11
  • How about providing actual code, and the actual data you're using with that code -- the real (copy/pasted, not retyped or edited) PHP code you're running. Timezones can be very tricky and the smallest oversight will throw things off. – alzee Aug 02 '16 at 04:50

0 Answers0