Re: Adding an DATETIME as a string to a mySQL databse....
| From: | php3 at developersdesk dot com | Date: | Wed, 12 Jul 2000 11:39:15 +0000 |
| Subject: | Re: Adding an DATETIME as a string to a mySQL databse.... | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-1068@lists.php.net to get a copy of this message | ||
Addressed to: Mattias Hedman <mattias@popwire.com>
<php-db@lists.php.net>
** Reply to note from Mattias Hedman <mattias@popwire.com> Wed, 12 Jul 2000 12:04:58 +0200
>
> Hello all, I am having troubles adding an value to an mySQL database,
> the row is set as DATETIME which should accept strings.
>
> When I build the string using DATE("Y-m-d H:i:s") in PHP and inserts
> it into the database the only thing that gets added in the row is
> DATETIME default value (0000-00-00 00:00:00).
>
> Why? Please help.
>
Please select ONE list to post to, there is no need to cross post to all
of them!
It might help to see the actual code. Is there an error message? That
DATE() format looks resonable. Have you looked at the actual query your
code creates?
<Wild guess alert!>
Do your quotation marks match properly in the query string?
</Wild guess alert!>
If you are trying to enter the current time/date, the easiest way is to
use the MySQL function NOW(). It returns the current time in a format
MySQL prefers.
If you have a UNIX time value it is easiest to use the MySQL function
FROM_UNIXTIME() to convert the timestamp.
There is quite a selection of functions to work with date/time values
listed in the MySQL manual.
http://www.mysql.com/documentation/mysql/commented/manual.php?section=Date_and_time_functions
See also:
http://www.mysql.com/documentation/mysql/commented/manual.php
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com