Ghost time appears when converting date format

Hi all,

Here’s something you probably don’t see everyday.

So we have a datetime $content[$i] in the format of “Saturday 13th of February 2010”

I’m adding on a “12:00pm” just so it gets a time too (not simply a date).

I then go and convert it into DATE_RFC822 for a RSS feed.

As soon as I do that and print it to the screen to check it magically inserts the current date into the string. In other words you’ll get the below:

Sat, 13 Feb 10 15:46:09 +0000

Surely there should be a) no time in there or b) 12:00pm in there if I append the 12:00pm to it before processing? Maybe I need to be forcing the 12:00pm part in there via another perhaps more datetime orientated method for it to play ball with me?

$content[$i] = $content[$i] ." 12:00pm";

$convert_date_obj = new DateTime(strtotime($content[$i]));
$convert_date_obj->setTimezone(new DateTimeZone(‘GMT’));
print "Result: " .$convert_date_obj->format(DATE_RFC822);

Thanks,

Sorry guys.

It would seem I’ve solved it via:

$convert_date_obj->setTime(12, 00, 00);

Surprisingly the modify method wouldn’t work though. Very picky.

strtotime on “Saturday 13th of February 2010” fails, your time jiggery-pokery doesn’t factor in. :wink: