Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-11-03 21:31:24

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

PHP and date > 2038?

I have a newbie question about PHP (I’m using 5.1) …

I’m trying to generate a very simple calendar, at any years (between 2000 and 2100). And date() is limited before 2038.

Does anyone know a simple replacement for it?

Offline

#2 2006-11-03 23:52:52

NyteOwl
Member
From: Nova Scotia, Canada
Registered: 2005-09-24
Posts: 539

Re: PHP and date > 2038?

Since PHP date functions use integer timestamps in calculations, year dates are restricted to 1901-2038 on POSIX type systems (Unix, Linux, BSD, etc) and 1970-2038 on Windows because of integer overflow for dates beyond those years.

You might try using a third party library like ADOdb or manually doing your calculations using unsigned integers or floating point rather than signed integer math.

Last edited by NyteOwl (2006-11-03 23:54:21)


Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;

Offline

#3 2006-11-04 01:45:12

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: PHP and date > 2038?

So what happens in 2038? :P

Offline

#4 2006-11-04 15:57:22

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: PHP and date > 2038?

By then the problem should be non-existent – we’ll all likely be using 64 bit machines.

PHP itself can’t handle unsigned integers. Here’s the ADOdb library (it uses floating points).

Offline

#5 2006-11-04 21:57:03

NyteOwl
Member
From: Nova Scotia, Canada
Registered: 2005-09-24
Posts: 539

Re: PHP and date > 2038?

PHP itself can’t handle unsigned integers.

I suspected as much but wasn’t certain as I’m still learning ins and outs of PHP. :)


Obsolescence is just a lack of imagination. / 36-bits Forever! / #include <disclaimer.h>;

Offline

#6 2006-11-05 00:26:22

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: PHP and date > 2038?

Thanks Mary, seems much more simple and effective than pear. I’ll try it.

Offline

Board footer

Powered by FluxBB