tags:

views:

75

answers:

3

Is there any function in PHP that either takes a date and turns it into a time stamp, or can simply take a date in one format and change it into another format? I have a set of dates in the format 'm d', which I want to change to 'l, F d, Y'.

I will need this with dates in other formats as well, so a function that lets me give it a date, input format and output format.

+1  A: 

DateTime::createFromFormat

Returns new DateTime object formatted according to the specified format

For output in a new format you have

DateTime::format

Or for a timestamp

DateTime::getTimestamp

Artefacto
This is exactly what I needed, thank you.
sgrif
A: 

use strtotime() and put it back in the date function like this:

date("l, F d, Y",strtotime($YOUR_MD_DATE));

Regards,
Dennis M.

RageD
+2  A: 

Try strtotime ( http://www.php.net/strtotime )

Kieran Allen
Only works with accepted date formats, which the input is not.
sgrif