例如:如果給定的日期小于今天的日期,它必須顯示為紅色,如果給定的日期大于今天的日期,它必須顯示為綠色。
uj5u.com熱心網友回復:
<?php
function getTheDay($date)
{
$curr_date=strtotime(date("Y-m-d H:i:s"));
$the_date=strtotime($date);
$diff=floor(($curr_date-$the_date)/(60*60*24));
switch($diff)
{
case 0:
return '<p style="color:green">Today</p>';
break;
case 1:
return '<p style="color:red">Yestarday</p>';
break;
default:
return $diff.' Days ago';
}
}
echo getTheDay('2021-11-21');
?>
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/362968.html
