470,849 Members | 1,037 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

Dates before 1969

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.

Jan 4 '06 #1
5 2165
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.

Jan 4 '06 #2
DJ Craig wrote:
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.


Have a look at the calendar functions:

http://www.php.net/calendar

Example:

$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:

http://www.php.net/gregoriantojd
JW

Jan 4 '06 #3
Thanks, that's exactly what I was looking for.

Jan 4 '06 #4
>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
You might consider using MySQL's date functions. The MySQL date
type will handle dates between 0 and 9999 (Y10K bug alert!).
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.


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
Jan 4 '06 #5
Janwillem Borleffs wrote:
DJ Craig wrote:
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.


Have a look at the calendar functions:

http://www.php.net/calendar

Example:

$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:

http://www.php.net/gregoriantojd
JW


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
suggested.

Thanks.

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.
Jan 5 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by will | last post: by
5 posts views Thread by PW | last post: by
10 posts views Thread by Colin Steadman | last post: by
1 post views Thread by Don Sealer | last post: by
9 posts views Thread by Bosconian | last post: by
1 post views Thread by pitfour.ferguson | last post: by
3 posts views Thread by Tgone | last post: by
2 posts views Thread by Jim Carlock | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.