NYCPHP Meetup

NYPHP.org

[nycphp-talk] mySQL datetime fields default now() fails

Brian Pang bpang at bpang.com
Sun Sep 7 12:49:02 EDT 2003


Phil,

I think you want to be using the timestamp column type instead.

http://www.mysql.com/doc/en/DATETIME.html

note that the value will be automatically set if you do not explicity
provide a value for it.

meaning...

if you want to preserve the original value on update, you need to return
the original value with the update query.

alternately, there are other mysql date/time functions you can use with
now() or current() that should work, just don't put them in quotes in
the insert statement.




> I figured it out but it's a PHP solution, not a mySQL solution:
> 
> date("Y-m-d H:i:s")
> 
> How inferior.  You can employ pre-defined constants in Oracle, SQL Server,
> even stinkin' ACCESS, but not mySQL?
> 




More information about the talk mailing list