Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert date

Status
Not open for further replies.

inusrat

Programmer
Joined
Feb 28, 2004
Messages
308
Location
CA
Hi

I have choosen "date" data type in my MYSQL table. Now I want to obtain the date from the syytem using PHP and insert it into the my table. In what format i need to have the date so that "date"
data type in MYSQL accepts it, I am the doing the following which I believe is not correct.

$orderdate=date("l dS of F Y h:i:s A");

$resultcat= mysql_query("insert into product_order values ('$fullname','$streetaddress' ,'$orderdate')")

Nothing get inserted for the date all I see 0000-00-00

Thanks



 
if its todays date you want inserting :

$resultcat= mysql_query("insert into product_order values ('$fullname','$streetaddress' ,curdate())")

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
But if you are inserting a date other than the MySQL server's current date, you need to pass MySQL a date string formatted as the PHP command

$orderdate=date('Y-m-d H:i:s');

would produce a date.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top