获取Unix时间戳中的实际日期,并将其转换为php中的gmt-3


get actual date in unix timestamp and the convert it to gmt-3 in php

我需要获得当前的unix时间戳,然后将其转换为我的本地时间,即GMT-3, Buenos Aires。

我已经做了一些研究,但是我就是找不到适合我问题的帖子。

询问实际日期:

  $date = new 'DateTime();

返回这个日期对象:

 object(DateTime)[28]
 public 'date' => string '2015-06-03 11:06:18.000000' (length=26)
 public 'timezone_type' => int 3
 public 'timezone' => string 'America/Buenos_Aires' (length=20)

如何访问timezone_type?如果我这样做,就会有错误日期-> timezone_type

以及如何将unix时间戳转换为gmt-3?

约会快把我逼疯了,请帮帮我

我希望下面的例子能对你有所帮助。

$day = date('Y-m-d', time());
$date = new DateTime($day, new DateTimeZone('Pacific/Nauru'));
echo $date->format('Y-m-d H:i:sP') . "'n";
$date->setTimezone(new DateTimeZone('Pacific/Chatham'));
echo $date->format('Y-m-d H:i:sP') . "'n";

示例输出为

2015-06-03 00:00:00+12:00
2015-06-03 01:45:00+13:45