473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2272
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: will | last post by:
The following piece of code should iterate through the months printing out the months and years combined. However date seems to have a preference for December 1969 after February 2004 (which of...
5
by: PW | last post by:
<rant> Sorry guys, but I just have to whinge. Dates in ASP are a total pain in the butt! I seem to get caught out so many times. I realise its my own fault, but going from the posts in this...
10
by: Colin Steadman | last post by:
I'm a stupid ASP programmer and I dont do Javascript (except for very simple tasks anyway), and I'm in a bit of a predicament. I've used a javascript table sorting script from here: ...
1
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from...
9
by: Bosconian | last post by:
I must be having a brain freeze because I can't figure out how to display dates older than 1970. I have birth dates stored in MySQL as "date" data types (exp. 1955-04-06). I'd like to display as...
12
by: Dixie | last post by:
I am trying to calculate the number of workdays between two dates with regards to holidays as well. I have used Arvin Meyer's code on the Access Web, but as I am in Australia and my date format is...
1
by: pitfour.ferguson | last post by:
My dbase has the start date and end date of each visit. How can I ask Access to list the day of the week of the start (easy), end (easy) and, more importantly, the dates of the visit itself - ie...
3
by: Tgone | last post by:
Hello, I need to convert a MySQL date "2007-03-08", into "March 8th, 2007". Normally I would use MySQL to accomplish this task but I have to use PHP. Here's my code: echo date("F jS, Y",...
2
by: Jim Carlock | last post by:
(1) Does PHP provide any way to handle dates prior to 1980? I know there's problems with Microsoft Windows NT and all Windows NT operating systems will allow a date prior to 1980 to be placed...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.