PHP ()函数用于获取当前的time.But,有一个问题!假设我们使用此函数获得当前时间12:05 AM (EST),那么如果我将这次与另一次时间(例如10:50 AM)进行比较,显然PHP会考虑10:50 AM的时间戳大于12:05 AM)..but实际上是错误的!12:05基本上是00:05 AM.!!我不知道如何准确地比较这样的时间,任何帮助都将不胜感激。
我用这段代码来比较这两次.
$current_time = time(); //suppose current time is 12:15 AM(returned by time() func)
$time1 = '1:30 AM';
$draw_time = strtotime($time1);
if($current_time < $draw_time1) {
echo 'Perfectos!';
} 发布于 2022-11-07 06:47:55
$current_time = time();
$time1 = date('d.m.Y') . ' 11:42 AM';
$draw_time = strtotime($time1);
echo ($draw_time) . " " . $current_time . "\r\n";
if ($current_time < $draw_time) {
echo 'True';
} else {
echo 'False';
}您可以这样做,您的代码是不正确的,因为您只获得第一个变量的小时和第二个变量的所有时间。
https://stackoverflow.com/questions/74342676
复制相似问题