我已更新了以下表格:
<?php
$date = new DateTime();
$date->setTimezone(new DateTimeZone('Asia/Kolkata'));
$fdate = $date->format('Y-m-d H:i:s');
$sql="update mytable set logged_on='$fdate' where id='$Id'";
?>
然后我尝试如下选择当前日期:
<?php
date_default_timezone_set('Asia/Kolkata');
$sql="select * from mytable where DATE(logged_on) = CURDATE()";
?>
但是CURDATE()无法正常工作。请告诉我如何按班级选择当前日期。
答案 0 :(得分:0)
这正在工作
<?php
$date = new DateTime();
$date->setTimezone(new DateTimeZone('Asia/Kolkata'));
$fdate = $date->format('Y-m-d H:i:s');
$sql="select * from mytable where DATE(logged_on) = Date($fdate)"
?>
但是我想更好的答案是
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
$con->query("SET GLOBAL time_zone = 'Asia/Calcutta'");
$con->query("SET time_zone = '+05:30'");
$con->query("SET @@session.time_zone = '+05:30'");
$sql="select * from mytable where DATE(logged_on) = CURDATE()";
?>