sg93 Posted November 1, 2006 Share Posted November 1, 2006 How do i get the timestamp of the first day in the week?I have tried [code]<?php $begin_week = strtotime( 'last Monday' ); ?>[/code]But that doesn't work...Any other functions to do the same? Link to comment https://forums.phpfreaks.com/topic/25827-find-the-first-day-of-the-week/ Share on other sites More sharing options...
alpine Posted November 1, 2006 Share Posted November 1, 2006 [code]<?phpecho date("d-m-Y", strtotime('last Monday')); // prints: 30-10-2006?>[/code]But note, on mondays this will get the previous monday Link to comment https://forums.phpfreaks.com/topic/25827-find-the-first-day-of-the-week/#findComment-117940 Share on other sites More sharing options...
Daniel0 Posted November 1, 2006 Share Posted November 1, 2006 [quote author=alpine link=topic=113485.msg461201#msg461201 date=1162400934]But note, on mondays this will get the previous monday[/quote]This will solve that problem: [code]<?php$begin_week = date('D')=="Mon" ? gmtime(0,0,0,date('m'),date('d'),date('Y') : strtotime('last Monday');?>[/code] Link to comment https://forums.phpfreaks.com/topic/25827-find-the-first-day-of-the-week/#findComment-117942 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.