7

I am unable to insert HTML5 default date format(mm/dd/yyyy) in mysql(YYYY-mm-dd).Please help is there any way to insert the html5 date into mysql. Or is it possible to change the html5/mysql date format?

<?php
  $name=$_POST['name'];
  $email=$_POST['email'];
  $password=$_POST['password'];
  $gender=$_POST['gender'];
  $bday=$_POST['bday'];
  include('connect.php');
  $y=mysql_query("insert into users values('$name','$email','$password','$gender','$bday')");
?>
Vinay Jain
  • 1,653
  • 20
  • 28

2 Answers2

3
<?php

$date = date('Y-m-d',strtotime($date));

?>
AbsoluteƵERØ
  • 7,816
  • 2
  • 24
  • 35
2

To change MySQL date format in your query you can use:

...since we can see your code

EDIT:

 mysql_query("insert into users values('$name','$email','$password','$gender',".date('Ymd',$bday))

Hope this helps...

Luigi Siri
  • 2,068
  • 2
  • 19
  • 27