如何将javascript日期更改为zend日期? 我将以格式发送日期:
Mon Nov 25 2013 12:00:00 GMT 0100
我这样想:
$date_tmp = new Zend_Date($date, false, 'pl_PL');
print_r($date_tmp->get('YYYY-MM-dd HH:mm:ss'));die();
但在输出中我得到:
2013-12-25 00:01:40
Insted of:
2013-12-25 12:00:00
也许时区错误设置?
答案 0 :(得分:0)
有bug in Zend_Date
when setting a time that crosses the DST change。
以下代码说明了问题:
date_default_timezone_set('America/New_York');
echo '<pre>';
// DST BEGINS '2012-03-11 02:00:00' - "Spring Forward"
$a = new Zend_Date('2012-03-11 00:00:00', 'yyyy-MM-dd HH:mm:ss');
$a->setTime('04:00:00', 'HH:mm:ss');
echo $a->toString('yyyy-MM-dd HH:mm:ss', 'iso')
. ' // expected: 2012-03-11 04:00:00' . PHP_EOL;
$b = new Zend_Date('2012-03-11 04:00:00', 'yyyy-MM-dd HH:mm:ss');
$b->setTime('00:00:00', 'HH:mm:ss');
echo $b->toString('yyyy-MM-dd HH:mm:ss', 'iso')
. ' // expected: 2012-03-11 00:00:00' . PHP_EOL;
// DST ENDS '2012-11-04 02:00:00' - "Fall Back"
$c = new Zend_Date('2012-11-04 00:00:00', 'yyyy-MM-dd HH:mm:ss');
$c->setTime('04:00:00', 'HH:mm:ss');
echo $c->toString('yyyy-MM-dd HH:mm:ss', 'iso')
. ' // expected: 2012-11-06 04:00:00' . PHP_EOL;
$d = new Zend_Date('2012-11-04 04:00:00', 'yyyy-MM-dd HH:mm:ss');
$d->setTime('00:00:00', 'HH:mm:ss');
echo $d->toString('yyyy-MM-dd HH:mm:ss', 'iso')
. ' // expected: 2012-11-06 00:00:00' . PHP_EOL;
echo '</pre>';
OUPUTS:
2012-03-11 05:00:00 // expected: 2012-03-11 04:00:00
2012-03-10 23:00:00 // expected: 2012-03-11 00:00:00
2012-11-04 03:00:00 // expected: 2012-11-06 04:00:00
2012-11-04 01:00:00 // expected: 2012-11-06 00:00:00