Click to See Complete Forum and Search --> : [RESOLVED] Date Function (Julian/Ordinal)


Tracer
02-15-2007, 09:36 AM
The function below worked GREAT under PHP4, but under PHP5 it fails. Does anyone have any ideas as to why? The function should take a human formatted date (mm/dd/YYYY) and convert it to a Julian/Ordinal (YYYYddd) Date.

function human_to_julian($date)
{

$utime = strtotime($date, "m/d/Y");

if (date(z, $utime)<10) {
$result = date(Y00z, $utime)+1;
return $result;
}
elseif (date(z, $utime)>=10 and date(z, $utime)<100) {
$result = date(Y0z, $utime)+1;
return $result;
}
elseif (date(z, $utime)>=100) {
$result = date(Yz, $utime)+1;
return $result;
}

}


The error I am receiving:
"strtotime() expects parameter 2 to be long"

TIA for any help in resolving this

Tracer
02-15-2007, 09:40 AM
I couldn't figure this out yesterday for the life of me... This morning as I'm posting it it's pretty obvious.. Heres the new function in case anyone ever needs it:

function human_to_tds($date)
{
$utime = strtotime($date);

if (date(z, $utime)<10) {
$result = date(Y00z, $utime)+1;
return $result;
}
elseif (date(z, $utime)>=10 and date(z, $utime)<100) {
$result = date(Y0z, $utime)+1;
return $result;
}
elseif (date(z, $utime)>=100) {
$result = date(Yz, $utime)+1;
return $result;
}
}