I have a problem with convert string datetime to timestamp in php.
$time = strtotime('2012-12-28 01:02:43');
echo $time; //it returns 1356627763
when I convert that integer value back to datetime it isn't correct (28/12/2012 00:02:43). Basically, it's late 1 hour.
my_format_datetime(strtotime('2012-12-28 01:02:43'));
Below is my my_format_datetime function :
> function my_format_datetime($unix)
> {
> if ($unix == '' || !is_numeric($unix))
> {
> $unix = strtotime($unix);
> }
> else
> {
> $timezone = 3600*(DEFAULT_GMT + date("0"));
> $unix = gmdate("d/m/Y H:i:s", $unix + $timezone);
> }
>
> return $unix;
> }
But when I convert using time() function it's correct.
Please help me. Thanks so much.
DEFAULT_GMT$timezone = 3600*(DEFAULT_GMT + date("0"));My guess would be the issue is with this.