Jump to content


Photo

Date and Time


  • Please log in to reply
2 replies to this topic

#1 JackJack

JackJack
  • Members
  • PipPipPip
  • Advanced Member
  • 38 posts

Posted 19 April 2006 - 09:08 AM

When i insert a new table in mysql i put the date as $date.

mysql_query("INSERT INTO `company_news` (date, sender, title, message, company)
VALUES ('$date', 'Updater', 'Company Name Updated', 'Your companys name has been updated to $name.', '$name')");



When i look at what has been added the date is always "0000-00-00 00:00:00".

Please help

JJ

#2 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 19 April 2006 - 10:02 AM

instead of using $date as the value to insert, use NOW().
This will generate a properly formatted date/time stamp for you...

or at least it does with my setup.

mysql_query("INSERT INTO `company_news` (date, sender, title, message, company)
VALUES ('NOW()', 'Updater', 'Company Name Updated', 'Your companys name has been updated to $name.', '$name')");

wisewood: proven fact, I am both wise, and wooden.

#3 reaper7861

reaper7861
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 19 April 2006 - 11:06 AM

also what is your declaration for date $date=? cause you can also declare it look here [a href=\"http://us3.php.net/manual/en/ref.datetime.php\" target=\"_blank\"]http://us3.php.net/manual/en/ref.datetime.php[/a]
or
[a href=\"http://us3.php.net/manual/en/function.date.php\" target=\"_blank\"]http://us3.php.net/manual/en/function.date.php[/a]

hope that helps, have a good day.


GCT




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users