Jump to content

Archived

This topic is now archived and is closed to further replies.

JackJack

Date and Time

Recommended Posts

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

[code]
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')");
[/code]


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

Please help

JJ

Share this post


Link to post
Share on other sites
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.

[code]
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')");
[/code]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.