Dates before 1969

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DJ Craig

    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.

  • Sjoerd

    #2
    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.

    Comment

    • Janwillem Borleffs

      #3
      Re: Dates before 1969

      DJ Craig wrote:[color=blue]
      > 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.[/color]

      Have a look at the calendar functions:



      Example:

      $jid = gregoriantojd(1 0, 15, 1582);
      print_r(cal_fro m_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:




      JW



      Comment

      • DJ Craig

        #4
        Re: Dates before 1969

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

        Comment

        • Gordon Burditt

          #5
          Re: Dates before 1969

          >I have written a program that uses the built-in PHP date functions.[color=blue]
          >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[/color]

          You might consider using MySQL's date functions. The MySQL date
          type will handle dates between 0 and 9999 (Y10K bug alert!).
          [color=blue]
          >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.[/color]

          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

          Comment

          • Erwin Moller

            #6
            Re: Dates before 1969

            Janwillem Borleffs wrote:
            [color=blue]
            > DJ Craig wrote:[color=green]
            >> 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.[/color]
            >
            > Have a look at the calendar functions:
            >
            > http://www.php.net/calendar
            >
            > Example:
            >
            > $jid = gregoriantojd(1 0, 15, 1582);
            > print_r(cal_fro m_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[/color]

            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.

            Comment

            Working...