# cat php_leap_second.php
假設程式是這樣寫的
這段程式 or PHP API 本身沒有處理好閏秒,
可能要想辦法用 EPOCH UNIT timestamp 避開此問題,而非使用 Wallclock string
<?PHP
$t1 = new DateTime('2012-06-30T23:59:59UTC');
$t2 = new DateTime('2012-06-30T23:59:60UTC');
$t3 = new DateTime('2012-07-01T00:00:00UTC');
$t4 = new DateTime('2012-07-01T00:00:01UTC');
print_r( $t2->diff($t1) );
print_r( $t3->diff($t1) );
print_r( $t3->diff($t2) );
print_r( $t4->diff($t2) );
?>
# php --version
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
# php php_leap_second.php
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 1
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 1
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 1
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 1
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 0 <---------- !!!!!!!! NO DIFF !!!!!!!!!!
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 0
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
DateInterval Object
(
[y] => 0
[m] => 0
[d] => 0
[h] => 0
[i] => 0
[s] => 1
[weekday] => 0
[weekday_behavior] => 0
[first_last_day_of] => 0
[invert] => 1
[days] => 0
[special_type] => 0
[special_amount] => 0
[have_weekday_relative] => 0
[have_special_relative] => 0
)
lie(t) = (1.0 - cos(pi * t / w)) / 2.0