PHP : strtotime() returns always 01/01/1970

HerrM picture HerrM · Jun 8, 2012 · Viewed 25.2k times · Source

I am trying to display dates in the European format (dd/mm/yyyy) with strtotime but it always returns 01/01/1970.

Here is my codeline :

echo "<p><h6>".date('d/m/Y', strtotime($row['DMT_DATE_DOCUMENT']))."</h6></p>";

In my database, the field is a varchar and records are formated like yyyy.mm.dd

I use the same codeline for another field that is formated like yyyy-mm-dd (varchar too) and it works fine.

Thanks for your help.

Answer

flowfree picture flowfree · Jun 8, 2012

Since the format yyyy-mm-dd works, try to replace . with -:

date('d/m/Y', strtotime(str_replace('.', '-', $row['DMT_DATE_DOCUMENT'])));