benjaminj88
23 Aug 2009, 02:33 PM
So I'm working on the display of my articles and currently I have all my articles saved with the date formatted with a datetime stamp so its like this yyyy-mm-dd hh:mm:ss so now here's what I was wondering on. I want the date to display but I want to reformat it so that it would display like this:
Mon. DD(st/nd/rd/th), YYYY
ex: Jan. 23rd, 2009
I was thinking of going about it this way:
$artMonth=substr($row[date],5,7);
switch($artMonth){
case 01:
$artMonth='Jan.';
break;
case 02:
$artMonth='Feb.';
break;
case 03:
$artMonth='Mar.'
break;
case 04:
$artMonth='Apr.';
break;
case 05:
$artMonth='May.';
break;
case 06:
$artMonth='Jun.';
break;
case 07:
$artMonth='Jul.';
break;
case 08:
$artMonth='Aug.';
break;
case 09:
$artMonth='Sep.';
break;
case 10:
$artMonth='Oct.';
break;
case 11:
$artMonth='Nov';
break;
case12:
$artMonth='Dec';
break;
default:
$artMonth='Error';
}
$artDay=substr($row[date],9,11);
switch (substr($artDay){
case 0,4,5,6,7,8,9:
$artDay="$artDay<sup>th</sup>,";
break;
case 1:
$artDay="$artDay<sup>st</sup>,";
break;
case 2:
$artDay="$artDay<sup>nd</sup>,";
break;
case 3:
$artDay="$artDay<sup>rd</sup>,";
$artYear=substr($row[date],0,4);
Let me know.
Mon. DD(st/nd/rd/th), YYYY
ex: Jan. 23rd, 2009
I was thinking of going about it this way:
$artMonth=substr($row[date],5,7);
switch($artMonth){
case 01:
$artMonth='Jan.';
break;
case 02:
$artMonth='Feb.';
break;
case 03:
$artMonth='Mar.'
break;
case 04:
$artMonth='Apr.';
break;
case 05:
$artMonth='May.';
break;
case 06:
$artMonth='Jun.';
break;
case 07:
$artMonth='Jul.';
break;
case 08:
$artMonth='Aug.';
break;
case 09:
$artMonth='Sep.';
break;
case 10:
$artMonth='Oct.';
break;
case 11:
$artMonth='Nov';
break;
case12:
$artMonth='Dec';
break;
default:
$artMonth='Error';
}
$artDay=substr($row[date],9,11);
switch (substr($artDay){
case 0,4,5,6,7,8,9:
$artDay="$artDay<sup>th</sup>,";
break;
case 1:
$artDay="$artDay<sup>st</sup>,";
break;
case 2:
$artDay="$artDay<sup>nd</sup>,";
break;
case 3:
$artDay="$artDay<sup>rd</sup>,";
$artYear=substr($row[date],0,4);
Let me know.