Convert string to timestamp in PHP using strtotime

10,156
$date = strtotime('Fri Apr 09 12:53:54 +0000 2010');
echo date('d/m/Y',$date);
echo $date;

Works for me. Check the the PHP version compability:
strtotime() api

Share:
10,156
Narek
Author by

Narek

Updated on June 29, 2022

Comments

  • Narek
    Narek almost 2 years

    Trying to change string like

    Tue Jun 28 15:24:51 +0000 2011
    

    to php unix time.

    Found this Parsing Twitter API Datestamp but strtotime returns -1 for me.

    echo strtotime('Fri Apr 09 12:53:54 +0000 2010');
    

    Any ideas? Probably hosting problems?

    Thanks

    This dinosaurs use PHP 4.4.9, so code doesn't work. I added

    AddType x-mapp-php5 .php
    

    and it starts to work:)