比较数组中的两个时间字符串

时间:2014-12-19 10:57:07

标签: php datetime string-comparison

我有一个看起来像那样的数组

[0] => 2014/12/18 02:44:26 GMT+05:30
[1] => 2014/12/18 02:44:27 GMT+05:30
[2] => 2014/12/18 02:44:37 GMT+05:30
[3] => 2014/12/18 02:44:47 GMT+05:30
[4] => 2014/12/18 02:44:57 GMT+05:30
. 
.
.

[6043] => 2014/12/18 23:17:47 GMT+05:30
[6044] => 2014/12/18 23:17:57 GMT+05:30
[6045] => 2014/12/18 23:18:02 GMT+05:30
[6046] => 2014/12/19 02:11:21 GMT+05:30
[6047] => 2014/12/19 02:11:22 GMT+05:30

我想比较两个时间字符串并获得最后一个索引,其中时间变为23比1意味着,不应超过一天(24 HR)

1 个答案:

答案 0 :(得分:0)

$time1 = "08:00:00";

if (strtotime($time1) < strtotime("23:59:00")) {
   ...
}