0

I don't know why this code give me this result:

$to= '2016/03/28';
$from = '2016/03/27';

$secs = strtotime($from) - strtotime($to);

returns:

1459116000 - 1459033200 = 82800,

all other days returns right value 86400

fusion3k
  • 11,568
  • 4
  • 25
  • 47
Mat_Tgn
  • 58
  • 1
  • 7
  • 1
    When does daylight saving time start? – andrewsi Feb 22 '16 at 17:15
  • 1
    Where do you get 82800? I tried your code and it returned -86400 for me. – Chin Leung Feb 22 '16 at 17:16
  • 3600 seconds = 1 hour, which almost ALWAYS is a timezone-related issue. – Marc B Feb 22 '16 at 17:16
  • This works fine on my machine, which leads me to believe it's an issue with how the time zone is configured on your box. – Ohgodwhy Feb 22 '16 at 17:17
  • Ok damn is a daylight saving problem. How i can edit my code to return the right value now? – Mat_Tgn Feb 22 '16 at 17:19
  • 1
    What is the right value? Then check if you're really absolutely sure that what you're getting isn't the real right value, because you seem to be working under the assumption that every day has 86400 seconds, and that's an incorrect assumption – Mark Baker Feb 22 '16 at 17:22
  • 1
    This result looks correct. 2016/03/27 is when daylight savings starts which means the day is not 24 hours. – apokryfos Feb 22 '16 at 17:24

0 Answers0