How to get the first date of the current month in PHP

2 Answers

0 votes
$date = new DateTime('first day of this month');
   
echo $date->format('jS, F Y');




/*
run:

1st, December 2023

*/

 



answered Dec 1, 2023 by avibootz
0 votes
$first_date_of_current_month = date('Y-m-01');
   
echo $first_date_of_current_month;




/*
run:

2023-12-01

*/

 



answered Dec 1, 2023 by avibootz

Related questions

1 answer 149 views
1 answer 153 views
153 views asked Mar 25, 2022 by avibootz
1 answer 156 views
1 answer 175 views
1 answer 160 views
1 answer 143 views
...