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开发者_StackOverflow中文版 this in PHP, right?
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);
$clean_string = str_replace(" +0000", "", $your_date_string);
should do the job
see str_replace doc
精彩评论