0

I have dates stored in a database that seem to be encoded weird. 06-02-2012 is in the database encoded as 1338661020. I figured that out by doing:

$date = new DateTime('@1338661020');
echo $date->format(DATE_ATOM);

How would I convert 06-02-2012 back to 1338661020 in PHP?

Solid Cloud
  • 5
  • 1
  • 2

1 Answers1

1

You can use strtotime() like this:

strtotime("06-02-2012")

strtotime() is a wonderful time function, can take just about any reasonable time format and covert it to Unix timestamp.

Sasha Pachev
  • 5,162
  • 3
  • 20
  • 20