I need to get the first and last day of a month in the format YYYY-MM-DD given only the month and year. Is there a good, easy way to do this?
php function days($date1, $date2) { $date1 = strtotime($date1); $date2 = strtotime($date2); return ($date2 - $date1) / (24 * 60 * 60); } $date1 = '20100820'; $date2 = '20100930'; echo days($date1, $date2); ?>
Get Last Day Of The Previous Month:$lastDay = date('t',strtotime('last month')); print_r($lastDay);
php $next_due_date = date('y-m-d',strtotime('+30 days',strtotime('echo $userRow3["due_date"]'))) .
date("m/d/Y", strtotime("last week monday")); date("m/d/Y", strtotime("last week sunday")); It will give the date of Last week's Monday and Sunday.
$first = date('Y-m-d', mktime(0, 0, 0, $month, 1, $year)); $last = date('Y-m-t', mktime(0, 0, 0, $month, 1, $year));
See date() in PHP documentation.
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