how to get month name from month-year (08-2022) string in php
i want to get this Aug-2022 (format) from my value 08-2022
I had tried date('m-Y',strtotime(08-2022))
and date('08-2022')->format('m-Y')
but not working.
CodePudding user response:
Just put a "01-" in front of your value to make it a valid date.
$value = "08-2022";
echo date('M-Y',strtotime('01-'.$value));
//Aug-2022
CodePudding user response:
you have to pass date also. so you can try like this way ...
$data = "08-2022";
$month = date('M-Y', strtotime('01-' . $data));
hope it helps ...