1,105,395 Community Members

Inserting a date into a database

bostonselkirk
Newbie Poster
5 posts since Oct 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

Hi all. As a hobby I've been working on making a website with PHP and MySQL, both of which I am new to. I'm having some trouble with the comments system as I can't seem to be able to insert a date into the database. After the "insert", when I check it, no date has been entered and the date defaults to 01 Jan 1970.

$arr['postDate'] = date('j F Y', date());

	mysql_query("	INSERT INTO comments(author,subject,email,comment,article_id,postDate)
					VALUES (
						'".$arr['author']."',
						'".$arr['subject']."',
						'".$arr['email']."',
						'".$arr['comment']."',
						'".$arr['article_id']."',
						'".$arr['postDate']."'
					)");

The column where the date is to be inserted is of type date. I figured this was a simple problem and that I could work it out from other examples but it seems to be taking me a lot longer than expected. I'd apreciate any help you can offer.
Thanks.

Member Avatar
pritaeas
mod_pritaeas
11,316 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 156 [?]
Moderator
Featured
Sponsor
 
0
 

A mysql date needs to be in the format '2011-09-23'

Question Answered as of 2 Years Ago by pritaeas
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: