【发布时间】:2017-07-06 18:57:50
【问题描述】:
我有一个具有 time 属性的实体。
在表单中,我有一个 TimeType。
我在表格中写的时间正是存储在 DB ex 中的时间。 14:54。但是当我从我的数据库中取回它时,我得到了 13:54。
我想这是一个时区问题,但我不知道如何处理这个问题。
我尝试设置model_timezone 和view_timezone,但似乎没有任何改变。
我的问题是没有 startTime 属性
编辑:这里有一些代码
实体
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
* BookingSession
*
* @ORM\Table(name="booking_session")
* @ORM\Entity(repositoryClass="AppBundle\Repository\BookingSessionRepository")
*/
class BookingSession
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"base"})
*/
private $id;
/**
* @var \DateTime
*
* @ORM\Column(name="date", type="datetimetz")
* @Groups({"base"})
*/
private $date;
/**
* @var \DateTime
*
* @ORM\Column(name="startTime", type="time")
* @Groups({"base"})
*/
private $startTime;
//...
表格
$builder
->add('startTime', 'time',['widget' => 'single_text','hours'=>$hours,"label"=>false,"attr"=>['class'=>'hidden']])
【问题讨论】:
-
你能给我们看一些代码,让我们知道我们在处理什么吗?