hi everyone,
i am retrieving some 25 dates from html table, and calculating.
suppose date is 03-feb-2009 i am converting it to 03-02-2009 and calculating with present date.
It gives the same answer to each and every date calculated,
any one helpme,
i have tried google n php.net,
its urgent
thanks a million in advance
<?php
function parse_array($string,$beg_tag,$close_tag)
{
preg_match_all("($beg_tag(.*)$close_tag)siU", $string, $matching_data);
return $matching_data[0];
}
$string=file_get_contents("callback.html");
$date1=parse_array($string,"<td nowrap=\"nowrap\">","</td>");
for($i=0;$i<count($date1);$i++)
{
echo $date1[$i]."</br>";
echo "</br>";
$date2=date("d-m-Y");
print "If we minus ".$date1[$i]." from ".$date2." we get ".dateDiff("-", $date2, $date1[$i]) . ".";
}
function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
if($date_parts1[1]=="Jan")
{
$date_parts1[1]='01';
}
if($date_parts1[1]=="Feb")
{
$date_parts1[1]='02';
}
if($date_parts1[1]=="Mar")
{
$date_parts1[1]='03';
}
if($date_parts1[1]=="Apr")
{
$date_parts1[1]='04';
}
if($date_parts1[1]=="May")
{
$date_parts1[1]='05';
}
if($date_parts1[1]=="Jun")
{
$date_parts1[1]='06';
}
if($date_parts1[1]=="Jul")
{
$date_parts1[1]='07';
}
if($date_parts1[1]=="Aug")
{
$date_parts1[1]='08';
}
if($date_parts1[1]=="Sep")
{
$date_parts1[1]='09';
}
if($date_parts1[1]=="Oct")
{
$date_parts1[1]='10';
}
if($date_parts1[1]=="Nov")
{
$date_parts1[1]='11';
}
if($date_parts1[1]=="Dec")
{
$date_parts1[1]='12';
}
$date_parts1[2]='20'.$date_parts1[2];
//$start_date=gregoriantojd(02,03,2009);
$start_date=gregoriantojd($date_parts1[1], $date_parts1[0], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[1], $date_parts2[0], $date_parts2[2]);
echo $date_parts1[0]."/".$date_parts1[1]."/".$date_parts1[2]."<br>";
echo $date_parts2[0]."/".$date_parts2[1]."/".$date_parts2[2]."<br>";
return floor(($end_date - $start_date)/86400)."<br>";
}
?>
this is my code