php echo out date end of month

$a_date = "2009-11-23";
echo date("Y-m-t", strtotime($a_date));

What is wrong - The most elegant for me is using DateTime

I wonder I do not see DateTime::createFromFormat, one-liner

$lastDay = \DateTime::createFromFormat("Y-m-d", "2009-11-23")->format("Y-m...

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. strtotime() is a PHP function that converts a string to a Unix timestamp. In our case, we are converting the string "2009-11-23" to a Unix timestamp.
2. strtotime() returns a Unix timestamp, which is a number used to represent

Snippet By Tony Lea

·

Created October 10th, 2021

·

Report Snippet