$dateString = $frontpageresultarray['SubmitDate']->format(DATE_RSS);
if($dateObject = new DateTime($dateString)){
// dateString was accepted
// now do something like $dateObject->diff($otherDateObject); to calculate the difference between the $dateObject and $otherDateObject
}else{
// date couldn't be converted
// refere to [date formats][1] for possible formats to use with DateTime
}
另一approcha是使用
$timestamp = strtotime(string $dateString);
$timestamp2 = strtotime(string $otherDateString);
$difference_in_seconds = $timestamp - $timestamp2;
$time_converted = date("d.m.Y",strtotime($dateString)); //takes the date in $time reads it converts it to unix timestamp and converts this timestamp via date back to string
那麼,什麼格式是它的權利嗎? – 2010-10-01 14:44:07
在SQL 2008數據庫中,它是日期時間格式 – Trinitrotoluene 2010-10-01 14:52:34