Jump to content

Form Date


moosey_man1988

Recommended Posts

Hi Everyone

 

I need to change the way my dates are put into mysql and also displayed

 

at the moment i have a javascript timepicker with validator that sets the date in the form as dd-mm-yy which displays as 25-05-2015 for example

 

and i have it attached to POST like so :  $dob = $_POST['dateofbirth'];

 

and then finally once the form is entered it does this

 

$sqlinsert = "INSERT INTO customers (prefix,Title,firstName,middleName,lastName,houseNo,Address1,postCode,ContactNo,DateOfBirth) VALUES ('$customer_prefix','$sex','$fname','$mname','$lname','$houseNo','$address1','$postcode','$contactno','$dob')";

 

but this puts the field in to the database wrong (e.g 22-05-2015) and I need to them go into the database like yyyy-mm-dd (e.g 2015-05-22)

 

I was thinking of doing something like this?

 

$originalDate = $dob;
$newDate = date("Y-m-d", strtotime($originalDate));

 

I also need to pull this information back out of the database once again in format dd-mm-yy

 

Thank you in advance for any help given.

Link to comment
https://forums.phpfreaks.com/topic/296444-form-date/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.