Page 1 of 1
Changing a dates format...
Posted: Sun Nov 24, 2002 11:02 am
by DynamiteHost
Ok... so I have this:
Its in DD MM YY format.
I need it to print 24th November 2002 instead...
How could I do this?
Posted: Sun Nov 24, 2002 11:10 am
by hob_goblin
http://www.php.net/manual/en/function.strtotime.php
or you could try exploding the string and handling each part...
Posted: Sun Nov 24, 2002 11:15 am
by DynamiteHost
I'm having difficulty understanding that page
Could you whip up some code for me quickly... please?

Posted: Sun Nov 24, 2002 11:47 am
by hob_goblin
Well, I just tried strtotime and it didn't work..
its going to be really hard to do it now..
Posted: Sun Nov 24, 2002 11:54 am
by hob_goblin
Code: Select all
<?
$date = "24 11 02";
$date = explode(" ", $date);
if(substr($dateї'2'], 0, 1) == "0"){
$dateї'2'] = "20".$dateї'2'];
} else {
$dateї'2'] = "19".$dateї'2'];
}
$date = implode(" ", $date);
function str2date($in){
$t = split("/",$in);
if (count($t)!=3) $t = split("-",$in);
if (count($t)!=3) $t = split(" ",$in);
if (count($t)!=3) return -1;
if (!is_numeric($tї0])) return -1;
if (!is_numeric($tї1])) return -2;
if (!is_numeric($tї2])) return -3;
if ($tї2]<1902 || $tї2]>2037) return -3;
return mktime (0,0,0, $tї1], $tї0], $tї2]);
}
echo date("dS F Y", str2date($date));
?>
it will work for 10 years... its a little y2k bug, because you put the year in only two digits.
Posted: Sun Nov 24, 2002 11:59 am
by DynamiteHost
ok, thanks for all your help (yet again)
