php 如何避免 1970前时间 时间戳失效了

WBOY
Release: 2016-06-13 13:31:43
Original
1015 people have browsed it

php 如何处理 1970前时间 时间戳失效了
最近涉及到做处理古代日期, 时间戳不能用了啊 date mktime 小于1970 就不行了

比如 1885-11-25 与 1901-01-12 日期差 就没法算了  

求高手帮助

------解决方案--------------------

PHP code
mysql_connect();
$d1 = '1901-01-12';
$d2 = '1885-11-25';
$rs = mysql_query("select TO_DAYS('$d1')-TO_DAYS('$d2')");
list($t) = mysql_fetch_row($rs);
echo $t;
<br><font color="#e78608">------解决方案--------------------</font><br>
<br>
Copy after login
PHP code
date_default_timezone_set('Asia/Hong_Kong');

$datetime1 = new DateTime('1885-11-25');
$datetime2 = new DateTime('1901-01-12');

$interval = $datetime1->diff($datetime2);
print_r($interval); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!