PHP中如何比较两个时间戳?

Riy*_*mad 1 php

在我的代码中,我有这样的场景:

<?php
     $start = "03:00:00:am";
     $end   = "08:00:00:pm";

      if($start > $end) {}   
?>
Run Code Online (Sandbox Code Playgroud)

我尝试使用 unix 时间戳,但没有成功。

Sch*_*eun 5

试试这个,我不认为末尾的 am、pm 是正确的格式,但对于日期,您应该能够以这种方式测试它们:

$start = strtotime("03:00:00");
$end   = strtotime("20:00:00");

if($start > $end) {}
Run Code Online (Sandbox Code Playgroud)