jd2007 Posted August 25, 2007 Share Posted August 25, 2007 What function to use to get the first day of the month ? Link to comment https://forums.phpfreaks.com/topic/66635-what-function-to-use-to-get-the-first-day-of-the-month/ Share on other sites More sharing options...
wildteen88 Posted August 25, 2007 Share Posted August 25, 2007 date and strtotime, eg: // date for the 1st of december 2007 $date = '01-12-2007'; // convert date into a timstamp $date_timestamp = strtotime($date); // get the day $day = date('l', $date_timestamp); echo $day; Link to comment https://forums.phpfreaks.com/topic/66635-what-function-to-use-to-get-the-first-day-of-the-month/#findComment-333844 Share on other sites More sharing options...
pkSML Posted August 25, 2007 Share Posted August 25, 2007 Here's how to get the first day of the current calendar month: <?php $day_of_week = date("l", mktime(0, 0, 0, date('n'), 1, date('Y'))); echo $day_of_week; ?> For August 2007, output is "Wednesday". See http://stephen.calvarybucyrus.org/misc/first_day_of_month.php Link to comment https://forums.phpfreaks.com/topic/66635-what-function-to-use-to-get-the-first-day-of-the-month/#findComment-333864 Share on other sites More sharing options...
Barand Posted August 25, 2007 Share Posted August 25, 2007 Wildteen, Alas, strtotime() does not recognise d/m/y or d-m-y <?php // date for the 1st of december 2007 $date = '01-12-2007'; // convert date into a timestamp $date_timestamp = strtotime($date); // now back to date again echo date ('Y-m-d', $date_timestamp); // 1970-01-01 ?> Link to comment https://forums.phpfreaks.com/topic/66635-what-function-to-use-to-get-the-first-day-of-the-month/#findComment-334002 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.