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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.