displaying pre-1970 dates

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

    displaying pre-1970 dates

    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 "April 4, 1955".

    I've tried using date("F j, Y"), but only get "December 31, 1969".

    I'm using PHP 4.3.8. Any suggestions would be appreciated.


  • Kim André Akerø

    #2
    Re: displaying pre-1970 dates

    Bosconian wrote:
    [color=blue]
    > 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 "April 4, 1955".
    >
    > I've tried using date("F j, Y"), but only get "December 31, 1969".
    >
    > I'm using PHP 4.3.8. Any suggestions would be appreciated.[/color]

    I'm guessing that you're also using this on a Windows box?

    From the PHP manual for the mktime function:
    "Before PHP 5.1.0, negative timestamps were not supported under any
    known version of Windows and some other systems as well. Therefore the
    range of valid years was limited to 1970 through 2038."

    --
    Kim André Akerø
    - kimandre@NOSPAM betadome.com
    (remove NOSPAM to contact me directly)

    Comment

    • Bosconian

      #3
      Re: displaying pre-1970 dates

      "Kim André Akerø" <kimandre@NOSPA Mbetadome.com> wrote in message
      news:44ig6jF2d0 dmU1@individual .net...[color=blue]
      > Bosconian wrote:
      >[color=green]
      > > 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 "April 4, 1955".
      > >
      > > I've tried using date("F j, Y"), but only get "December 31, 1969".
      > >
      > > I'm using PHP 4.3.8. Any suggestions would be appreciated.[/color]
      >
      > I'm guessing that you're also using this on a Windows box?
      >
      > From the PHP manual for the mktime function:
      > "Before PHP 5.1.0, negative timestamps were not supported under any
      > known version of Windows and some other systems as well. Therefore the
      > range of valid years was limited to 1970 through 2038."
      >
      > --
      > Kim André Akerø
      > - kimandre@NOSPAM betadome.com
      > (remove NOSPAM to contact me directly)[/color]

      Actually no, it's Linux (MDK 10.1). Sorry, I should have mentioned that. And
      yes, I'm aware of the Windows limitation and have read (and re-read) the
      php.net date function docs and user comments (which is usually helpful, but
      not in this case.) I even checked google.groups for clues, but no dice.

      I can always roll my own output function, but I don't understand why this
      isn't working.


      Comment

      • Dave Kelly

        #4
        Re: displaying pre-1970 dates

        Bosconian wrote:[color=blue]
        > 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 "April 4, 1955".
        >
        > I've tried using date("F j, Y"), but only get "December 31, 1969".
        >
        > I'm using PHP 4.3.8. Any suggestions would be appreciated.
        >
        >[/color]
        This is from somebody that probably don't know what he is talking about.

        The manual says that 'date' is used to set the SYSTEM date and time.

        That should be why you are being blocked by the epoach wall. Not a
        system in the world has a last modified date of 4/4/1955.

        Comment

        • Bosconian

          #5
          Re: displaying pre-1970 dates

          "Dave Kelly" <daveekelly@ear thlink.net> wrote in message
          news:3TVEf.1010 7$1n4.3142@news read2.news.pas. earthlink.net.. .[color=blue]
          > Bosconian wrote:[color=green]
          > > I must be having a brain freeze because I can't figure out how to[/color][/color]
          display[color=blue][color=green]
          > > dates older than 1970.
          > >
          > > I have birth dates stored in MySQL as "date" data types (exp.[/color][/color]
          1955-04-06).[color=blue][color=green]
          > > I'd like to display as "April 4, 1955".
          > >
          > > I've tried using date("F j, Y"), but only get "December 31, 1969".
          > >
          > > I'm using PHP 4.3.8. Any suggestions would be appreciated.
          > >
          > >[/color]
          > This is from somebody that probably don't know what he is talking about.
          >
          > The manual says that 'date' is used to set the SYSTEM date and time.
          >
          > That should be why you are being blocked by the epoach wall. Not a
          > system in the world has a last modified date of 4/4/1955.[/color]

          Is it possible that you know even less?

          Anyone remotely familiar with the date function knows you can pass a second
          timestamp argument. I thought my previous message implied this. Shame on me.

          From the docs:

          string date ( string format [, int timestamp] )

          Returns a string formatted according to the given format string using the
          given integer timestamp or the current local time if no timestamp is given.
          In other words, timestamp is optional and defaults to the value of time().

          Linux-based servers support negative timestamps. I tried using strtotime,
          but to no avail.


          Comment

          • Gordon Burditt

            #6
            Re: displaying pre-1970 dates

            >I must be having a brain freeze because I can't figure out how to display[color=blue]
            >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 "April 4, 1955".[/color]

            I recommend formatting it with MySQL's date_format() function.

            e.g.

            SELECT date_format(bir thdate, "%M %e, %Y") from table where ...;

            MySQL's datetime format manages to cover years from 1 to 9999.

            Gordon L. Burditt

            Comment

            • Chuck Anderson

              #7
              Re: displaying pre-1970 dates

              Bosconian wrote:
              [color=blue]
              >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 "April 4, 1955".
              >
              >I've tried using date("F j, Y"), but only get "December 31, 1969".
              >
              >I'm using PHP 4.3.8. Any suggestions would be appreciated.
              >
              >
              >
              >[/color]
              $months = array('', 'January', 'February', 'March', 'April', 'May',
              'June', 'July', 'August', 'September', 'October', 'November', 'December');

              Separate year, month and day with strtok or explode and format it yourself.

              --
              *************** **************
              Chuck Anderson • Boulder, CO

              Integrity is obvious.
              The lack of it is common.
              *************** **************

              Comment

              • Bosconian

                #8
                Re: displaying pre-1970 dates

                "Chuck Anderson" <websiteaddress @seemy.sig> wrote in message
                news:zJKdnbLTB-hYmHjenZ2dnUVZ_ v2dnZ2d@comcast .com...[color=blue]
                > Bosconian wrote:
                >[color=green]
                > >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.[/color][/color]
                1955-04-06).[color=blue][color=green]
                > >I'd like to display as "April 4, 1955".
                > >
                > >I've tried using date("F j, Y"), but only get "December 31, 1969".
                > >
                > >I'm using PHP 4.3.8. Any suggestions would be appreciated.
                > >
                > >
                > >
                > >[/color]
                > $months = array('', 'January', 'February', 'March', 'April', 'May',
                > 'June', 'July', 'August', 'September', 'October', 'November', 'December');
                >
                > Separate year, month and day with strtok or explode and format it[/color]
                yourself.[color=blue]
                >[/color]

                Yup, that's exactly what I did. I made the months array global because it's
                used elsewhere.

                // custom output function for displaying pre-1970 dates; expects
                "yyyy-mm-dd" date format
                // returns full textual month, numeric day (w/o leading zeros) and numeric
                4-digit year
                function format_date($da te) {
                global $months;
                return $months[intval(substr($ date, 5, 2))] . ' ' . intval(substr($ date,
                8, 2)) . ', ' . substr($date, 0, 4);
                }


                Comment

                • Bosconian

                  #9
                  Re: displaying pre-1970 dates

                  "Gordon Burditt" <gordonb.z8la0@ burditt.org> wrote in message
                  news:11u8eefk2s da38b@corp.supe rnews.com...[color=blue][color=green]
                  > >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.[/color][/color]
                  1955-04-06).[color=blue][color=green]
                  > >I'd like to display as "April 4, 1955".[/color]
                  >
                  > I recommend formatting it with MySQL's date_format() function.
                  >
                  > e.g.
                  >
                  > SELECT date_format(bir thdate, "%M %e, %Y") from table where ...;
                  >
                  > MySQL's datetime format manages to cover years from 1 to 9999.
                  >
                  > Gordon L. Burditt[/color]

                  You're absolutely correct; this can be done in the query and is actually
                  faster that way.

                  However, when it's abolutely necessary in PHP the function posted in my
                  previous message works nicely.


                  Comment

                  • Jim Michaels

                    #10
                    Re: displaying pre-1970 dates


                    "Bosconian" <bosconian@plan etx.com> wrote in message
                    news:fsmdncthba zDsnnenZ2dnUVZ_ vudnZ2d@comcast .com...[color=blue]
                    > "Dave Kelly" <daveekelly@ear thlink.net> wrote in message
                    > news:3TVEf.1010 7$1n4.3142@news read2.news.pas. earthlink.net.. .[color=green]
                    >> Bosconian wrote:[color=darkred]
                    >> > I must be having a brain freeze because I can't figure out how to[/color][/color]
                    > display[color=green][color=darkred]
                    >> > dates older than 1970.
                    >> >
                    >> > I have birth dates stored in MySQL as "date" data types (exp.[/color][/color]
                    > 1955-04-06).[color=green][color=darkred]
                    >> > I'd like to display as "April 4, 1955".
                    >> >
                    >> > I've tried using date("F j, Y"), but only get "December 31, 1969".
                    >> >
                    >> > I'm using PHP 4.3.8. Any suggestions would be appreciated.
                    >> >
                    >> >[/color]
                    >> This is from somebody that probably don't know what he is talking about.
                    >>
                    >> The manual says that 'date' is used to set the SYSTEM date and time.
                    >>
                    >> That should be why you are being blocked by the epoach wall. Not a
                    >> system in the world has a last modified date of 4/4/1955.[/color]
                    >[/color]

                    My version 5 manual http://us3.php.net/manual/en/function.date.php doesn't
                    say that it sets the system time. You must be looking at the unix man pages
                    for the program "date". PHP manual says it just says it returns a formatted
                    string.
                    in the version 5 manual it states this:
                    Note:
                    The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54
                    GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond
                    to the minimum and maximum values for a 32-bit signed integer). However,
                    before PHP 5.1 this range was limited from 01-01-1970 to 19-01-2038 on some
                    systems (e.g. Windows).

                    maybe a PHP upgrade is in order, if possible?

                    [color=blue]
                    > Is it possible that you know even less?
                    >
                    > Anyone remotely familiar with the date function knows you can pass a
                    > second
                    > timestamp argument. I thought my previous message implied this. Shame on
                    > me.
                    >
                    > From the docs:
                    >
                    > string date ( string format [, int timestamp] )
                    >
                    > Returns a string formatted according to the given format string using the
                    > given integer timestamp or the current local time if no timestamp is
                    > given.
                    > In other words, timestamp is optional and defaults to the value of time().
                    >
                    > Linux-based servers support negative timestamps. I tried using strtotime,
                    > but to no avail.
                    >
                    >[/color]


                    Comment

                    Working...