mktime()和UNIXTIME时代。 [英] mktime() and UNIXTIME epoch.

查看:87
本文介绍了mktime()和UNIXTIME时代。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨。


在我的Linux RedHat 8系统上,我不能使用PHP获得1970年以前的日期。

也就是说,喂食时将dfates转换为unixtime的函数,例如

mktime()和strtotime()


打印日期(" Ym-d",mktime(0) ,0,0,1,1,1930));

- > " 1969-12-31" (因为mktime的结果是-1)


但是date()得到了它,所以如果我这样做的话


打印date(" Ym-d",-1000000000);

- > 1938-04-24


现在,大概这与Linux而不是PHP有关,因为在MySQL中做这个没有b $ b这不是''工作要么:


选择unix_timestamp('''1935-12-03'');

- > 0


但是,使用perl时,使用Date :: Manip时效果很好:


#!/ usr / bin / perl

使用Date :: Manip;

$ date = UnixDate(" 1945-01-23","%s");

打印$ date;

- > -787021200


那么,为什么MySQL无法做到这一点,PHP无法做到,但perl可以不知何故?我可以用
编译带负整数日期支持的PHP吗?


-

Sandman [.net]

Hi.

On my Linux RedHat 8 system, I can''t obtain dates earlier than 1970 with PHP.
That is, when feeding a function that turns dfates into unixtime, such as
mktime() and strtotime()

print date("Y-m-d", mktime(0,0,0,1,1,1930));
-> "1969-12-31" (since the result of mktime is "-1")

But date() gets it though, so if I do

print date("Y-m-d", -1000000000);
-> "1938-04-24"

Now, presumably this has something to do with Linux instead of PHP, since doing
this in MySQL doesn''t work either:

select unix_timestamp(''1935-12-03'');
-> 0

But, when using perl, it works just fine when using Date::Manip:

#!/usr/bin/perl
use Date::Manip;
$date = UnixDate("1945-01-23", "%s");
print $date;
-> -787021200

So, how come MySQL can''t do it, PHP can''t do it, but somehow perl can? Can I
compile PHP with negative integer date support?

--
Sandman[.net]

推荐答案

date = UnixDate(" 1945-01-23","%s");

print
date = UnixDate("1945-01-23", "%s");
print


date;

- > -787021200


那么,为什么MySQL无法做到这一点,PHP无法做到,但perl可以不知何故?我可以用
编译带负整数日期支持的PHP吗?


-

Sandman [.net]
date;
-> -787021200

So, how come MySQL can''t do it, PHP can''t do it, but somehow perl can? Can I
compile PHP with negative integer date support?

--
Sandman[.net]


嗨桑德曼!


2004年2月18日星期三09:59:52 +0100,Sandman< mr@sandman.net>写道:
Hi Sandman!

On Wed, 18 Feb 2004 09:59:52 +0100, Sandman <mr@sandman.net> wrote:
嗨。

在我的Linux RedHat 8系统上,我不能使用PHP获得1970年以前的日期。
这是,当提供将dfates转换为unixtime的函数时,例如
mktime()和strtotime()

打印日期(Ym-d,mktime(0,0,0, 1,1,1930));
- > " 1969-12-31" (因为mktime的结果是-1)

但是date()得到了它,所以如果我这样做的话打印日期(Ym-d) ,-1000000000);
- > 1938-04-24

现在,大概这与Linux而不是PHP有关,因为在MySQL中做这个也不起作用:

选择unix_timestamp('''1935-12-03'');
- > 0

但是,使用perl时,使用Date :: Manip时效果很好:

#!/ usr / bin / perl
使用Date :: Manip;
Hi.

On my Linux RedHat 8 system, I can''t obtain dates earlier than 1970 with PHP.
That is, when feeding a function that turns dfates into unixtime, such as
mktime() and strtotime()

print date("Y-m-d", mktime(0,0,0,1,1,1930));
-> "1969-12-31" (since the result of mktime is "-1")

But date() gets it though, so if I do

print date("Y-m-d", -1000000000);
-> "1938-04-24"

Now, presumably this has something to do with Linux instead of PHP, since doing
this in MySQL doesn''t work either:

select unix_timestamp(''1935-12-03'');
-> 0

But, when using perl, it works just fine when using Date::Manip:

#!/usr/bin/perl
use Date::Manip;


这篇关于mktime()和UNIXTIME时代。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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