moisesbr Posted August 15, 2013 Share Posted August 15, 2013 Hi A date is expressed in character format as below: $date_course = "22/08/2013" ; # day/month/year I am trying to insert it in mysql table using: $date=date("Y-m-d",strtotime($date)); But I imagine is not enough and I have to convert it to "2012/08/22" before transforming it to date. Please help me to clarify this issue and solve it. Moises Link to comment https://forums.phpfreaks.com/topic/281193-characters-to-date/ Share on other sites More sharing options...
gristoi Posted August 15, 2013 Share Posted August 15, 2013 you can use the datetime object in PHP: $date = DateTime::createFromFormat('d/m/Y', $date_course); $dateForDb = $date->format('Y-m-d'); hope that helps Link to comment https://forums.phpfreaks.com/topic/281193-characters-to-date/#findComment-1445125 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.