PDA

View Full Version : How could I reformat a date which is already formatted


brothercake
02-20-2005, 04:37 AM
I've got a string which is a pattern for the date() function:

$date_format = 'l jS F Y';

And I want to reformat any date which is already stored in RFC822 format, using that pattern (or whatever pattern it is).


Does that make sense? Basically, how do I get from any date formatted like this:

Sat, Feb 12 2005 07:12:02 GMT

To the same date formatted with a different pattern ...?

Fou-Lu
02-20-2005, 04:43 AM
strtotime() (http://ca3.php.net/manual/en/function.strtotime.php) is probably what you are looking for.

brothercake
02-22-2005, 06:13 PM
Okay thanks - so is there a way to get directly from the UTC time figure, to a date re-formatted with date(), or will I have to it indirectly, by passing the number to getdate() and then formatting it myself from the information that produces?

marek_mar
02-22-2005, 10:16 PM
I didn't get that but have you tryed:

print date('l jS F Y', strtotime('Sat, Feb 12 2005 07:12:02 GMT'));

??

brothercake
02-22-2005, 11:41 PM
Er no ... I didn't even know date() could take a second argument ... :o

But I do now :thumbsup:

Ultragames
02-23-2005, 04:50 AM
Niether did I. Cool!