1

I have the following date and time in an RSS feed:

Fri, 01 Oct 2010 12:26:57 +0000

However I just want to display:

Fri, 01 Oct 2010 12:26:57

There should be a really simple way to do this in PHP, right?

CLiown
  • 13,665
  • 48
  • 124
  • 205
  • possible duplicate of [PHP convert one date into another date format](http://stackoverflow.com/questions/2167916/php-convert-one-date-into-another-date-format) – Pekka Oct 06 '10 at 13:09
  • Here is a better dupe: http://stackoverflow.com/questions/3337088/strtotime-to-convert-both-date-and-time – Pekka Oct 06 '10 at 13:12

2 Answers2

5

If you don't mind showing the date in UTC/GMT (I forget which), then just use substring to strip off the +0000. However, if you want local time, you'll have to convert the string to a timestamp and then format the timestamp back to a date string.

$uncleandate = 'Fri, 01 Oct 2010 12:26:57 +0000';
$timestamp = strtotime($uncleandate);
$cleandate = date('D, d M Y H:i:s', $timestamp);
villecoder
  • 13,323
  • 2
  • 33
  • 52
0

$clean_string = str_replace(" +0000", "", $your_date_string); should do the job

see str_replace doc