We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,973 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Inserting a date into a database

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.

2
Contributors
1
Reply
1 Hour
Discussion Span
1 Year Ago
Last Updated
2
Views
Question
Answered
bostonselkirk
Newbie Poster
5 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

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

pritaeas
Posting Prodigy
Moderator
9,268 posts since Jul 2006
Reputation Points: 1,173
Solved Threads: 1,457
Skill Endorsements: 86
Question Answered as of 1 Year Ago by pritaeas

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0570 seconds using 2.7MB