lil*_*lly 29 php postgresql timezone datetime
我在Postgres上使用Doctrine2.在一个表中,我有两种不同的日期类型:birthdate:date
和created_at:datetimetz
.两者都成为DateTime对象但具有不同timezone_type
.这是列表:
created_at
datetimetz:
DateTime Object
(
[date] => 2013-04-18 11:54:34
[timezone_type] => 1
[timezone] => +02:00
)
Run Code Online (Sandbox Code Playgroud)
birthdate
日期:
DateTime Object
(
[date] => 1970-01-01 00:00:00
[timezone_type] => 3
[timezone] => Europe/Berlin
)
Run Code Online (Sandbox Code Playgroud)
我需要以相同的方式格式化我的对象.两者都应该有timezone_type=3
.
我怎样才能做到这一点?
vas*_*ite 68
时区可以是DateTime对象中三种不同类型之一:
new DateTime("17 July 2013 -0300");
new DateTime("17 July 2013 GMT");
new DateTime( "17 July 2013", new DateTimeZone("Europe/London"));
只有附加了类型3时区的DateTime对象才能正确使用DST.
为了始终具有类型3,您需要将数据库中的时区存储为此列表中的可接受标识符,并在实例化时将其应用于DateTime对象.