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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.