php mysql datetime

2011-01-21T01:18:17

I have two tables in MySQL, and each table has its own datetime field. I want to copy the datetime of table A to overwrite the datetime of table B. I use PHP.

$result = mysql_query("select * 
                         from A 
                        where id = $key");
$row = mysql_fetch_array($result);
print $row[2]."\n"; // $row[2] is the datetime field
mysql_query("update B 
                set date_cal = $row[2]  
              where id = $key") // try to overwrite datetime in table B

$row[2] has the string representation of datetime field.

But the overwrite operation does not take effect. How to do to overwrite datetime field of table B using php?

If I insist using $row[2] to assign the new datetime field rather running mysql_query again, how to do?

Copyright License:
Author:「chnet」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/4750329/php-mysql-datetime

About “php mysql datetime” questions

I have two tables in MySQL, and each table has its own datetime field. I want to copy the datetime of table A to overwrite the datetime of table B. I use PHP. $result = mysql_query("select * ...
I want to ask about changing a datetime value of PHP with datetime value from MySQL data. I have try to do this at PHP: $sitgl = date('Y-m-d', strtotime(2012-01-12)); $sijam = date('H:i:s', strto...
I have a task to read datetime from csv file by PHP and store them in mysql database. There are two format of datetime in csv file, the first is DD/MM/YYYY HH:mm:ss AM/PM, the second is MM-DD-YYYY ...
I have problems comparing dates between a date created with new dateTime () in php, and a date taken from a DATETIME field of a Mysql table. With the following code, save a date in a DATETIME fiel...
I have a PHP class that represent MySQL table. One of that column table type is DateTime. Previously I use string and everything work fine, because I don't have to deal with the date type. I just use
I have a PHP class that represent MySQL table. One of that column table type is DateTime. Previously I use string and everything work fine, because I don't have to deal with the date type. I just use
I am trying to insert the datetime into a column in a mysql table. <?php //Some code date_default_timezone_set('Europe/London'); //Other variables defined also $date_time = new DateTime();
I have a MYSQL datetime that looks like this - 2011-08-28 12:39:21 I need (in PHP) to see if the time is within 3 minutes of the current time. I know how to do it in MySQL like 'BETWEEN NOW()-INTE...
I want to use PHP to insert date into mysql datetime field. $time = date('Y-m-d'); mysql_query(INSERT INTO A (date) VALUE ('$time')); Table A date column is datetime field. I want it shows 2011-...
I'm confused about timezone differences when converting a MySQL datetime to Unix timestamp. It appears to me that MySQL datetimes (2011-02-07 09:45:00) are in the server's local timezone. I want to

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.