您好我有一个应用程序将插入比较并将当前时间插入MySQL数据库。比较是在PhP文件上。如何更改时区(即我的GMT + 8),以便插入的数据为GMT +8(与MySQL数据比较时的时间戳也是GMT +8)
我试过这个但是没有用。插入的时间未转换为特定时区。任何帮助都非常感激。感谢
//set timezone
date_default_timezone_set: "Asia/Singapore";
我的完整博士文件
<?php
if($_SERVER['REQUEST_METHOD']=='POST'){
//set timezone
date_default_timezone_set: "Asia/Singapore";
// decoding the json array
$post = json_decode(file_get_contents("php://input"), true);
$eventID = $post['EventID'];
require_once('dbconnect.php');
$result = array();
foreach ($eventID as $value){
// $sql = "SELECT EventID, EventTitle, EventDesc, EventTime FROM Event WHERE EVENTID = '$value'";
$sql = "SELECT * FROM Event WHERE EVENTID = '$value' && EventEndTime>=NOW()";
// $sql = "SELECT * FROM Event WHERE EVENTID = '$value'";
$res = mysqli_query($con,$sql);
while ($row = mysqli_fetch_array($res)){
array_push($result,array(
'EventID'=>$row['EventID'],
'EventTitle'=>$row['EventTitle'],
'EventDesc'=>$row['EventDesc'],
'EventStartTime'=>$row['EventStartTime'],
'EventEndTime'=>$row['EventEndTime'],
));
}
}
// echo json_encode(array('result'=>$result));
header('Content-Type: application/json');
echo json_encode(array('result'=>$result), 256);
mysqli_close($con);
}