我正在使用SQL查询中的NOW()函数。我想将其更改为另一个时区。这是否可能?
尝试了以下函数:
class common {
public function getTime() {
$date = new DateTime();
$date->setTimezone(new DateTimeZone('Europe/Paris'));
return $date->format('Y-m-d H:i:s');
}
}
并且出现以下错误
Catchable fatal error: Object of class common could not be converted to string in line below
$stmt = $this->db->prepare("INSERT INTO `items`
(`refno`, `color`, `size`, `qt`, `stackno`, `notes`, `price`, `add_date`)
VALUES (?, ?, ?, ?, ?, ?, ?, $this->common->getTime())") or die($db->error);
我做错了什么?