gpt4 book ai didi

php - IntlDateFormatter::parse 不起作用?

转载 作者:搜寻专家 更新时间:2023-10-31 21:59:11 25 4
gpt4 key购买 nike

我正在尝试解析日期,但我得到了错误的时间戳

<?php
// PHP version 5.5.9
// intl version 1.1.0
// ICU version 52.1
// ICU Data version 52.1

// I'm in Europe/Moscow (GMT +3)
echo date_default_timezone_get().PHP_EOL;

$df = \IntlDateFormatter::create(
'en_EN',
IntlDateFormatter::MEDIUM,
IntlDateFormatter::NONE,
'Europe/Moscow' // GMT +3
);

$timestamp = $df->parse('Jun 19, 2015');

// 1434657600 - wrong timestamp! Where is 1 hour? Must be 1434657600 + 3600 = 1434661200
echo $timestamp.PHP_EOL;

$dt = new \DateTime();
$dt->setTimestamp($timestamp);

// Thu, 18 Jun 2015 23:00:00 +0300 - wrong, must be Thu, 19 Jun 2015 00:00:00 +0300
echo $dt->format('r').PHP_EOL;

// or using date():
// echo date('r', $tm).PHP_EOL;

最佳答案

通过从存储库更新 ICU 解决 https://launchpad.net/~rzz/+archive/ubuntu/icu

关于php - IntlDateFormatter::parse 不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30934986/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com