Page 1 of 1
Convert String From RSS Feed - Date
Posted: Wed Sep 08, 2004 12:21 pm
by submike
I need some help converting the following date from a RSS feed into a more user-friendly date format.
From RSS Feed:
2004-09-17T00:00:00
Ideally, I would like it to appear as follows:
September 17, 2004
If that's too complicated, the following works too:
09-17-2004
Thanks in advance for any help,
Mike
Posted: Wed Sep 08, 2004 1:05 pm
by m3mn0n
What code do you have so far?
Posted: Wed Sep 08, 2004 2:33 pm
by submike
I think I solved my problem. Let me know if there's any way to streamline the code or a different approach.
Code: Select all
<?php
$month_arr = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$start_date = "2004-09-17T00:00:00";
$today = explode("-",$start_date);
$gyear = $today[0];
$gmonth = (substr_replace($today[1], '', 0, -1) - 1);
$gday = substr_replace($today[2], '', 2);
echo $month_arr[$gmonth]." ".$gday.", ".$gyear;
?>
Posted: Wed Sep 08, 2004 3:15 pm
by submike
Here's the final approach I settled on.
Code: Select all
<?php
$month_arr = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$start_date = "2004-09-17T00:00:00";
$gyear = substr($start_date, 0, 4);
$gmonth = (substr($start_date, 5, 2) - 1);
$gday = substr($start_date, 8, 2);
echo $month_arr[$gmonth]." ".$gday.", ".$gyear;
?>