Jump to content

Insert date to database


nanie

Recommended Posts

Hi, I'm currently using date picker for selecting event date in my form codes. But I have problem when trying to insert to the database.

 

The date picker display value as this,

October 9th, 2013

I try to convert it using this code from another forum,

$eventDate=$_POST['eventdate'];

//check date format here before continuing.
list($day,$month,$year)=explode('/',$eventDate);
$timestamp=mktime(0,0,0,$month,$day,$year);
$final_date=date('Y-m-d',$timestamp); 

echo $final_date; // to see the conversion

and this is what i get back

Warning: mktime() expects parameter 5 to be long, string given .....................
1970-01-01 

Please help me, I want to get this value -----> 09/10/2013

Link to comment
Share on other sites

  • 2 weeks later...
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.