Reputation: 1
I have a DatePicker that gives me a value like this "10-Nov-2016". I want to convert this date into a SQL Date such as "2016/10/22".
What would be the best way to do this?
Any help appreciated, thank you.
Upvotes: 0
Views: 311
Reputation: 28524
use date() and strtotime() function
echo date('Y/m/d', strtotime('15-Feb-2009'));
Upvotes: 0
Reputation: 451
Use DateTime::createFromFormat or procedural version date_create_from_format.
$date = DateTime::createFromFormat('j-M-Y', '15-Feb-2009');
echo $date->format('Y/m/d');
Upvotes: 1