Jump to content

Date and Time


JackJack

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
Link to comment
https://forums.phpfreaks.com/topic/7826-date-and-time/
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]
Link to comment
https://forums.phpfreaks.com/topic/7826-date-and-time/#findComment-28511
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
Link to comment
https://forums.phpfreaks.com/topic/7826-date-and-time/#findComment-28521
Share on other sites

Archived

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

×
×
  • Create New...

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.