943,558 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 883
  • PHP RSS
Dec 4th, 2008
0

PHP Date always returns 0

Expand Post »
I am trying to insert a date into a mysql table field using
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. $date=date(Y-m-d);
  3. mysql_query("INSERT INTO table VALUES('$date')");
  4. ?>

but when I open up mysql and run SELECT * FROM table; it returns a date value of 0000-00-00 instead of the current date at time of insert. Am I misunderstanding something with the php date function?
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocnib is offline Offline
6 posts
since Sep 2008
Dec 4th, 2008
0

Re: PHP Date always returns 0

It was quotes around the date format string. Why does the obvious always become obvious only after you ask for help?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pocnib is offline Offline
6 posts
since Sep 2008
Dec 15th, 2008
0

Re: PHP Date always returns 0

i think you have to use
date_default_timezone_set('yourtime zone');
for me it is as follows
date_default_timezone_set('Asia/Calcutta');
then call date();
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Word Press MU
Next Thread in PHP Forum Timeline: Php page containing html form to sql database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC