947740 Posted May 30, 2008 Share Posted May 30, 2008 Let us say that I have a day that is not Monday (E.G. today) as a unix timestamp: $date = strtotime("now"). How do I change $date to the timestamp of the Monday in the week of the original date? I.E., how would I change the value of $date to this Monday's timestamp? Link to comment https://forums.phpfreaks.com/topic/108070-solved-getting-the-unix-timestamp-of-monday-in-the-current-week/ Share on other sites More sharing options...
Barand Posted May 31, 2008 Share Posted May 31, 2008 this should work <?php $dow = (date('w') + 6) % 7; $monday = strtotime("-$dow days"); echo date (' D jS M Y', $monday); // Mon 26th May 2008 ?> Link to comment https://forums.phpfreaks.com/topic/108070-solved-getting-the-unix-timestamp-of-monday-in-the-current-week/#findComment-553934 Share on other sites More sharing options...
947740 Posted June 2, 2008 Author Share Posted June 2, 2008 Thanks Barand. I ended up using a switch statement, but your way is much shorter. Link to comment https://forums.phpfreaks.com/topic/108070-solved-getting-the-unix-timestamp-of-monday-in-the-current-week/#findComment-555692 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.