Jump to content

problem in insert date in my sql


chennaibala

Recommended Posts

hi frd....

      i have a problem in insert date in my sql using php.i have show to user "8-Oct-2009",while inserting it must "2009-Oct-8",because mysql allow yyyy-mon-dd format only.how to change data format while insert?can i use strtok($info, $tokens);?or any suggestion..thanks in advances

 

Link to comment
https://forums.phpfreaks.com/topic/176941-problem-in-insert-date-in-my-sql/
Share on other sites

Hi chennaibala,

 

It depends on how the Calendar stores the date variable, if you post your code it would be easier for us to give a more definitive answer but you could explode() the date returned from the database and then output it in the desired format.

 

e.g.

 

$newdate = explode($date);

echo $newdate[0];
echo $newdate[1];
echo $newdate[2];

 

But post your code for a more definitive answer.

 

Hope this helps.

here is my piece of coding

 

<input name="zdate" type="text" size="12" id="z1date" >

 

by using Calendar,user wil select date .selected date in dispaly in zdate text box in "8-Oct-2009" format.

 

by using post method,i get date value frm text box

 

$ndate=$_POST["zdate"];

 

so value present in $ndate is 8-Oct-2009.but these format is not insert in mysql

thanks cags..i got solution from tips..great..superb..doubt to verify frm u...

 

$ndate1=$_POST["zdate"];

$date = date("Y-m-d", strtotime($ndate1));..these code run perfect..no problem in it..

 

when i try by these

 

$date = date("Y-m-d", strtotime($_POST["zdate"]));..i get error..these problem in insert...wht may be problem...??thanks in advances for ur reply...

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.