I have a date in a variable like: 01-01-2009 and need to change the format to Y-m-d. What should I use to do this conversion?
You can use the strtotime
and date
functions like this:
$str = '01-01-2009';
$date = date('Y-m-d', strtotime($str));
echo $date; //2009-01-01
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