0

我有一个来自纪元的毫秒字段,例如 1350393140000。我需要在 PhP 中将此字段作为日期时间,将其时间部分更改为上午 7 点(UTC 时间)并将其从纪元转换回毫秒。我怎样才能做到这一点?

4

2 回答 2

2
$input = 1350393140000;

$dt = new DateTime('@' . floor($input / 1000));
$dt->setTimeZone(new DateTimeZone('UTC'));
$dt->modify('07:00');

$output = $dt->format('U') * 1000;
于 2012-10-16T13:16:52.450 回答
0
date_default_timezone_set('UTC');
$ts = 1350393140000 / 1000;
$ts = mktime(7, date('i', $ts), date('s', $ts), date('n', $ts), date('j', $ts), date('Y', $ts));
$ts = $ts * 1000;
于 2012-10-16T13:17:08.267 回答