Jump to content

Recommended Posts

As I see it, there are several options.  I know of several javascript scripts that popup and let you choose the date.  Or could just use a textfield and put the requested format next to it (like mm/dd/yy).

 

When you process that with the php script, you will want to format the date accordingly.  Using $date = strtotime($_POST['date']) and then take the date("n/j/Y",$date) will give you a good format.  Then you just insert into the database.

Link to comment
https://forums.phpfreaks.com/topic/161508-solved-input-date/#findComment-852300
Share on other sites

i input date as:

  Quote
<input type="date" name="date">

 

and retrieve it using

 

  Quote
$date = strtotime($_POST['date']);

$deadline = date("n/j/Y",$date);

 

and add in database:

 

  Quote
$add_deadline = "INSERT INTO goals_deadline (goal_id, deadline)

VALUES ('$goal_id','$deadline')";

$result = mysql_query ($add_deadline) or die(mysql_error());

 

 

But the date is not inserted in database.  echo $deadline;  is giving the correct value but it is not inserted in database while the $goal_id is being inserted every time.

 

Please Help!

 

 

Link to comment
https://forums.phpfreaks.com/topic/161508-solved-input-date/#findComment-852916
Share on other sites

There's no date type for input fields, use text instead:

 

<input type="text" name="date" />

 

And try inserting a date in the standard format instead (YYYY-MM-DD), your current format is not recognized by MySQL:

 

$date = strtotime($_POST['date']);
$deadline = date('Y-m-d', $date);

Link to comment
https://forums.phpfreaks.com/topic/161508-solved-input-date/#findComment-852921
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.