我正在使用此脚本来比较php中的两个日期列。我有图像文件夹,并希望将所有符合日期的图像合并为一个xml。图片格式为“entry_145_BD12ZZU_2014-06-25_12-26-58”.jpg
if(file_exists($xmlFullFilename)) {
if($entryTimeNode->format("Y-m-d") = $entryTimeNode->format("Y-m-d"))** this is what I tried.
$xmlDoc = new DomDocument();
$tmp = split(" ", $entryTime);
$dateString = $tmp[0] . "T" . $tmp[1];
$entryTimeNode = $xmlDoc->createElement("EntryTime", $dateString);
XML文件
<Incidents xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Count="2" Date="2014-10-24" Time="12:05:39" FileName="2014-10-24_Brook_Retail_Park.xml">
<Incident>
<EntryTime>**2014-10-17**T11:17:44</EntryTime>
</Incident>
<Incident>
<EntryTime>**2014-10-17**T16:19:15</EntryTime>
</Incident></Incidents>
答案 0 :(得分:0)
mostly date also compare with as like normal variable like:
$a=5;
$b=10;
if($a > $b){
//Blalala
}
and in date also you can compare like this
$c=2014/10/29;
$d=2014/10/29;
if($c > $d){
//Blalala
}
and i can't more figure out from question you have date with time so in your case,
$e=**2014-10-17**T11:17:44
$f=**2014-10-17**T16:19:15
$first_date_ary=explode("**", $e);
$second_date_ary=explode("**", $f);
and then compare your date, as per i mention above
if($first_date_ary[0] > $second_date_ary[0]){
//Blalala
}
and sorry for bad English too.