为什么php在php中返回负值? [英] why strotime returns negative value in php?

查看:134
本文介绍了为什么php在php中返回负值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用strtotime将日期转换为unixtime邮票。
年份,日期和日期作为不同的代码值,我使用以下代码生成时间戳。

I am using strtotime to convert a date to a unixtime stamp. Year, date and day comes as different values to code and I am using the below code to produce the timestamp.

$year  = '1961';
$month = '2';
$day   = '15';

$date  = $year."-".$month."-".$day;

echo strtotime($date);

上面的代码打印:-27648000为我。如果这个年份在1970年以上,就会打印出积极的结果。我还在学习时间戳,如果有人可以帮助我。主要目的是将日期转换为unix时间戳。

The above code prints : -27648000 for me. If the year is above 1970 it prints out positive results. I am still learning with the timestamp, if any one can help me out. The main aim is to convert a date to unix timestamp.

问题是为什么会产生负面结果,我编码不好!我也试过mktime,但仍然是一样的结果。

The questions is why it gives negative results, Am I coding it bad!? I am also tried mktime, but still the same result.

谢谢,
Tanmay

Thanks, Tanmay

推荐答案

它与Unix Epoch有关。

It's to do with the Unix Epoch.

请参阅: date() time()

See: date() and time()

时间戳的有效范围通常是从Fri,13 Dec 1901 20:45:54 GMT到Tue,1938年01月19日03:14:07 GMT。 (这些是对应于32位有符号整数的最小值和最大值的日期)。但是,在PHP 5.1.0之前,某些系统的这个范围从01-01-1970到19-01-2038

The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer). However, before PHP 5.1.0 this range was limited from 01-01-1970 to 19-01-2038 on some systems

这篇关于为什么php在php中返回负值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆