I want to output of last and first date of a given month of current year. I am using this code but not works
$month='02';
$first_day_this_month = date('Y-'.$month.'-01'); // hard-coded '01' for first day
$last_day_this_month = date('Y-'.$month.'-t');
echo $first_day_this_month;print'<->';echo $last_day_this_month;
my output shows
2015-02-01<->2015-02-31
But it will be 2015-02-01<->2015-02-28
I have had this problem with PHP before, try the following way:
$dateToTest = "2015-02-01";
$lastday = date('t',strtotime($dateToTest));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With