我需要将其中一个数组值与一个日期进行比较。
例如,
$first_date = array ( [0] => 24-10-13 [1] => 18-10-13 );
$my_date = 01-10-13;
我需要比较,我的日期是否在$first_date
数组之间。
答案 0 :(得分:1)
$first_date = array ('01-10-13', '18-10-13');
$my_date = '11-10-13';
if(strtotime($my_date) > strtotime($first_date[0]) && strtotime($my_date) < strtotime($first_date[1])) {
// Do some
}
答案 1 :(得分:0)
<?php
$first_date = array ( '24-10-13','18-10-13');
$my_date[] = '18-10-13';
$result = array_intersect($first_date, $my_date);
print_r($result);
?>
答案 2 :(得分:0)
首先,您的日期格式应为24-10-2013,现在您可以使用strtotime()更改数组中的每个日期以及要检查的其他日期
$strtdate=strtotime($first_date[1]);
$enddate=strtotime($first_date[0]);
$checkdate=strtotime($my_date);
现在你知道你可以使用if语句并且小于和大于检查你的日期是否在这两天之间。
if($strtdate<=$checkdate && $checkdate<=$enddate)
{
echo "date is in between";
}else{
echo "not between";
}