您可以在以下位置找到这些字符串:https://www.php.net/manual/en/datetime.formats.relative.php。
所以我认为您正在寻找的是:
<?php
$start = "01-10-2019";
$end = "31-10-2019";
$test = "01-11-1968";
$start = new \DateTime($start);
$end = new \DateTime($end);
$test = new \DateTime($test);
function isBetweenDateIgnoreYear(\DateTime $startInput,\DateTime $endInput,\DateTime $checkInput)
{
$start = clone $startInput;
$end = clone $endInput;
$check = clone $checkInput;
$currentYear = (int) date('Y');
$start->setDate($currentYear,(int) $start->format('m'),(int) $start->format('d'));
$end->setDate($currentYear,(int) $end->format('m'),(int) $end->format('d'));
$check->setDate($currentYear,(int) $check->format('m'),(int) $check->format('d'));
return ($start <= $check && $check <= $end);
}
$result = isBetweenDateIgnoreYear($start,$end,$test);
var_dump($result);
,
{{ date('today') | format_datetime() }}
date
(以及 date_modify
)使用 PHP 的 strtotime
函数。 today
指当天的 00:00:00,如 PHP’s relative format reference 中所述。
本文链接:https://www.f2er.com/3150629.html