strtotime display one date before in php

107 views Asked by At

I've a date in the format dd/mm/YYYY. Eg: 25/06/2015. I want convert it to timestamp. I've added the following code to implement this;

$timestamp = strtotime( str_replace( '/', '-', '25/06/2015' ) );

It creates timestamp, but when I convert that timestamp I can see that it is one day before. When I execute the above code, I got the timestamp value "1435183200". When I convert this I got the previous date "24/06/2015".

If anybody knows the solution to fix this, please help.

1

There are 1 answers

0
visevo On

I think you have the default timezone configured in PHP. Try switching your timezone. Use:

date_default_timezone_set('your_timezone_here');

For a list of supported timezones, go to http://php.net/manual/en/timezones.php