Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get first date and last date of previous month in php?

Tags:

php

I want to get previous month first date and last date.

$first_date = strtotime('first day of previous month', time());
$previous_month_first_date=date('Y-m-d', $first_date);
$previous_month_last_date=date('Y-m-d', strtotime('last day of previous month'));
like image 969
ranojan Avatar asked Dec 06 '25 14:12

ranojan


1 Answers

=> Try this code I hope it's useful ..

echo date('Y-m-d', strtotime('first day of last month'));

echo "<br/>";

echo date('Y-m-d', strtotime('last day of last month'));

Output:- https://eval.in/925253

like image 187
Nimesh Patel Avatar answered Dec 08 '25 03:12

Nimesh Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!