-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-dates.php
More file actions
23 lines (17 loc) · 889 Bytes
/
test-dates.php
File metadata and controls
23 lines (17 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
$format = "Y-m-d H:i:s";
$startDate = date('Y-m-d 00:00:00', strtotime("+10 days"));
$endDate = date('Y-m-d 00:00:00', strtotime("+60 days"));
$input = date('Y-m-d 00:00:00', strtotime("2016-01-29"));
echo "startDate:\t". $startDate . "\n";
echo "endDate: \t". $endDate . "\n";
$startDatetime = DateTime::createFromFormat($format, $startDate);
$endDatetime = DateTime::createFromFormat($format, $endDate);
$inputDatetime = DateTime::createFromFormat($format, $input);
var_dump($startDatetime);
var_dump($endDatetime);
var_dump($inputDatetime);
if(($inputDatetime->getTimestamp() >= $startDatetime->getTimestamp()) && ($inputDatetime->getTimestamp() <= $endDatetime->getTimestamp()))
{
echo $input . " is beteween " . $startDate . " and " . $endDate . "\n";
}