<?php
$format = 'Y-m-d H:i:s';
$days_left = 7;
$date = time();
echo date($format,'12 days ago')."\n";
$dateParts = explode('-', date('Y-m-d', $date));
var_dump(DateInterval::createFromDateString("12 days ago"));
$start = mktime(0,0,0, $dateParts[1], intval($dateParts[2])-$days_left, $dateParts[0]);
echo date($format,$start)."\n";
$end = mktime(0,0,0, $dateParts[1], intval($dateParts[2])-($days_left-1), $dateParts[0]);
echo date($format,$end);
- Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.26, 7.3.0 - 7.3.13, 7.4.0 - 7.4.1
- Notice: A non well formed numeric value encountered in /in/AO4Qd on line 5
1970-01-01 01:00:12
object(DateInterval)#1 (16) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(-12)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["f"]=>
float(0)
["weekday"]=>
int(-7)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
2015-10-29 00:00:00
2015-10-30 00:00:00
- Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
- Notice: A non well formed numeric value encountered in /in/AO4Qd on line 5
1970-01-01 01:00:12
object(DateInterval)#1 (15) {
["y"]=>
int(0)
["m"]=>
int(0)
["d"]=>
int(-12)
["h"]=>
int(0)
["i"]=>
int(0)
["s"]=>
int(0)
["weekday"]=>
int(-7)
["weekday_behavior"]=>
int(0)
["first_last_day_of"]=>
int(0)
["invert"]=>
int(0)
["days"]=>
bool(false)
["special_type"]=>
int(0)
["special_amount"]=>
int(0)
["have_weekday_relative"]=>
int(0)
["have_special_relative"]=>
int(0)
}
2015-10-29 00:00:00
2015-10-30 00:00:00
preferences:
141 ms | 403 KiB | 196 Q