Dates before 1969

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have written a program that uses the built-in PHP date functions.
All that the program does is calculate the amout of time between two
dates, or calculate the date a certain amount of time before or after
another date.  It works, but I didn't realize until after I finished it
that it won't work for dates outside the range of 1969-2033.  I need it
to work for any date going back to the 1500s for pairs of dates that
are up to about 400 years apart.  Is there any way that I can fix my
program without having to start over writing my own date functions?  My
program uses the strtotime() and date() functions.

Re: Dates before 1969

The maximum range with the date() and strtotime() functions is from
Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. The
second parameter is the time in seconds stored in an int. An int has a
limited range, so a date has also a limited range.

Re: Dates before 1969

DJ Craig wrote:
Quoted text here. Click to load it

Have a look at the calendar functions:


$jid = gregoriantojd(10, 15, 1582);
print_r(cal_from_jd($jid, CAL_GREGORIAN));

Don't forget to read the notice regarding the application of Gregorian  
calendars with dates before 1582-10-15 on the following page:


Re: Dates before 1969

Thanks, that's exactly what I was looking for.

Re: Dates before 1969

Janwillem Borleffs wrote:

Quoted text here. Click to load it

Thanks too.

That is also excactly what I was looking for. :-)
I added a note to date() for people to look at calendar too, like you  


Erwin Moller

PS: I hate dates and computers. I hated them when I did Java, I hated them  
when I did VB, I hate them always.

Re: Dates before 1969

Quoted text here. Click to load it

You might consider using MySQL's date functions.  The MySQL date
type will handle dates between 0 and 9999 (Y10K bug alert!).

Quoted text here. Click to load it

MySQL also has date_format and str_to_date.

I am not sure what calendar is used for datediff(), as gaps in  
the calendar and other strangeness like variations in the beginning
day of the year will also affect the results.

                        Gordon L. Burditt

Site Timeline