Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

strtotime date weird result

Tags:

date

php

Given the following string date: Fri Sep 02 2011 21:00:00 GMT+0100 (GMT Daylight Time)

in php if I do a strtotime on the above, and then convert it back to a string date, it seems to gain an hour.

echo $str_date,"  Vs ",date("c",strtotime($str_date));

Produces:

Fri Sep 02 2011 21:00:00 GMT+0100 (GMT Daylight Time) Vs 2011-09-02T22:00:00+01:00

I realise this is to do with daylight savings, but how does one compensate for this?

like image 328
Kevin Bradshaw Avatar asked Sep 02 '11 09:09

Kevin Bradshaw


1 Answers

I think you misunderstanding,
there is not day light saving in this case,
BUT GMT, you gain one hour because of that

in my timezone (GMT+8)

php -r "echo date('r', strtotime('Fri Sep 02 2011 21:00:00 GMT+0100'));"
Sat, 03 Sep 2011 04:00:00 +0800

which I gain 7 hours, due to GMT+8 - GMT+1 = 7

like image 183
ajreal Avatar answered Sep 26 '22 06:09

ajreal