简体   繁体   中英

Grab current first and last day in week in php

How do I grab and show dates for the first and last day in the current week we're in.

So in this current week it would output:

2012-05-14  -  2012-05-20

(It's 2012-05-17 today)

How can this be done simply?

try use strtotime

$first = date('Y-m-d',strtotime("last monday"));
$last = date('Y-m-d',strtotime("next sunday"));

other examples

strtotime('monday this week');
strtotime('sunday this week');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM