我有一个问题是中午/下午12点每天都在变化。
让我们想象一下:
$objToday = new DateTime("today", new DateTimeZone('Asia/Jakarta'));
$objTomorrow = new DateTime("tomorrow", new DateTimeZone('Asia/Jakarta'));
if (// today time has not been passed 12.00 p.m) {
// get Today at 12.00 p.m
echo "$objToday->format("Y-m-d G:i:s")";
}
else {
// this "else" means the time has passed from 12.00 p.m (today)
// so, it's automaticly change to (tommorow) at 12.00 p.m
// get Tomorrow at 12.00 p.m
echo "what to do here?";
}
应该用什么方法解决这个问题?
感谢..
答案 0 :(得分:1)
尝试以下
$info = getdate();
if ($info['hours'] < 12) {
// get Today at 12.00 p.m
echo "$objToday->format("Y-m-d G:i:s")";
}
else {
echo "what to do here?";
}
答案 1 :(得分:0)
$date->modify('tomorrow')
然后格式化为中午12点。