Reputation: 4987
Using a Php date functions i would like to get the last week date ranges,
for example.
its Friday, 24th June 2016 Today.
I want the out put
Last week Start Date : 2016-06-13 (YYYY-mm-dd Format)
Last week End Date : 2016-06-19 (YYYY-mm-dd Format)
Is that possible ?
Upvotes: 4
Views: 7087
Reputation: 1574
<?php
echo date("Y-m-d", strtotime("last week monday"));
echo "<br>";
echo date("Y-m-d", strtotime("last sunday"));
?>
Upvotes: 8
Reputation: 5049
Try:
$start_week = strtotime("last monday midnight");
$end_week = strtotime("+1 week",$start_week);
$start_week = date("Y/m/d",$start_week);
$end_week = date("Y/m/d",$end_week);
echo $start_week.' '.$end_week ;
Upvotes: 0
Reputation: 89
Yes, it is possible. Use strtotime()
Date formats
strtotime('sunday', 'Fri June 24th, 2016"')
strtotime('monday', 'Fri June 24th, 2016"')
Upvotes: 0