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:
strtotime
date
$str = '01-01-2009'; $date = date('Y-m-d', strtotime($str)); echo $date; //2009-01-01
2.1m questions
2.1m answers
60 comments
57.0k users