RE: Re: datetime update

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually it would be:
UPDATE table SET dateTime=NOW() WHERE record_id='$the_one_you_want';

Or
INSERT INTO table (record_id,dateTime) VALUES
('$the_one_you_want',NOW());


Gary Every
Sr. UNIX Administrator
Ingram Entertainment Inc.
2 Ingram Blvd, La Vergne, TN 37089
"Pay It Forward!"

-----Original Message-----
From: roehr@xxxxxxxxxxx [mailto:roehr@xxxxxxxxxxx] 
Sent: Thursday, June 10, 2004 4:10 AM
To: php-db@xxxxxxxxxxxxx
Subject:  Re: datetime update

>Hi all,
>
>i have a datetime field in a mysql database and it's defined with a
default
>of '0000-00-00 00:00:00:'
>
>now, when i add a record to the database, i want to fill that field
with >the date and current time.
>
>can anyone point me ?

Via PHP:
$dateTime = date('Y-m-d H:i:s');
mysql_query("INSERT INTO table SET dateTime = '$dateTime'");

Via MySQL:
mysql_query("INSERT INTO table SET dateTime = NOW()");

Take a look here for other useful MySQL date and time functions:
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

Hope it helps. Regards,

Torsten Roehr

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux