我正在尝试在记录呼叫时将开始日期和时间自动设置为用户当前的日期和时间。这是在加载视图之前设置的。
该代码正在运行,但没有考虑到我的时区,它比英国时间格林威治标准时间晚了一个小时。
如何确保时区正确。
class CustomCallsController extends SugarController
{
public function action_log_inbound()
{
global $timedate;
if(!isset($timedate) || empty($timedate))
{
$timedate = new TimeDate();
}
// get user for calculation
$user = (empty($user)) ? $this->user : $user;
$this->bean->direction = 'Inbound';
$this->bean->date_start = $timedate->asUser($timedate->getNow(), $user);
echo $this->bean->date_start;
$this->view = 'edit';
}
}