mysql - How to format date in db with php -


i want change format of date:

if (!empty($_post['dob']) && !empty($_post['mob']) && !empty($_post['yob'])) {     $yob = mysqli_real_escape_string($con, $_post['yob']);     $mob = mysqli_real_escape_string($con, $_post['mob']);     $dob = mysqli_real_escape_string($con, $_post['dob']);     $date = mysqli_real_escape_string($con, "$yob->$mob->$mob");     $addtothedb = "insert login (dateofbirth) values ('". $date . "')";               $result = mysqli_query($con, $addtothedb); } 

however data db yyyy-mm-dd whereas have dd-mm-yyyy.

you use http://php.net/manual/en/function.date.php function desired format.

$result = date('d-m-y', strtotime($birthdate)); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -