Pretty simple to some people, but pretty new to PHP. I just want to insert today date into a date field in MySQL
Thanks in advance.
$sql = "UPDATE IA SET IASubmitted ='yes', IASubmittedDate='date('Y-m-d')' WHERE Reference='$Reference'";
$result=mysql_query($sql);
I think the simplest answer is as follows:
$sql = "UPDATE IA SET IASubmitted ='yes', IASubmittedDate='". date('Y-m-d'). "' WHERE Reference='$Reference'";
$result=mysql_query($sql);
try this :
$date = date('Y-m-d');
sql = "UPDATE IA SET IASubmitted ='yes', IASubmittedDate='". $date. "' WHERE Reference='$Reference'";
$result=mysql_query($sql);
hope this can help you.
Try this
sql = "UPDATE IA SET IASubmitted ='yes', IASubmittedDate='" DATE_FORMAT(NOW(),'%Y-%m-%d') "' WHERE Reference='$Reference'";
$result=mysql_query($sql);
You can simply do this without the php date()
function by using MySQLs CURDATE()
function. This should look like this
$sql = "UPDATE IA SET IASubmitted ='yes', IASubmittedDate=CURDATE() WHERE Reference='$Reference'";
$result=mysql_query($sql);
You can also use:
$sql = "UPDATE IA SET IASubmitted ='yes', IASubmittedDate=now() WHERE Reference='$Reference'"; $result=mysql_query($sql);
This will work both: when IASubmittedDate is date or IASubmittedDate is datetime
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.