Timestamps for 1800's

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

    #1

    Timestamps for 1800's

    I'm trying to convert this date:
    12 May1868
    Into this:
    18690512
    That's YYYYMMDD. So first I need to convert it to a UNIX time stamp
    using the strtotime() function, then convert it to YYYYMMDD. This
    works for more rescent dates:
    $d = date('Ymd', strtotime($d));
    I tested that with 19 July2005, and it worked. But the strtotime()
    function seems to return -1 for dates before the UNIX epoch. How can I
    convert these dates?

  • Michel

    #2
    Re: Timestamps for 1800's

    have the monthnames in an array.
    split on spaces
    loop array until you find the right month
    add 1 (or have array[0]='none'; )
    put string together in your format
    done

    "DJ Craig" <spit@djtriciti es.com> wrote in message
    news:1121869645 .273644.174560@ o13g2000cwo.goo glegroups.com.. .[color=blue]
    > I'm trying to convert this date:
    > 12 May1868
    > Into this:
    > 18690512
    > That's YYYYMMDD. So first I need to convert it to a UNIX time stamp
    > using the strtotime() function, then convert it to YYYYMMDD. This
    > works for more rescent dates:
    > $d = date('Ymd', strtotime($d));
    > I tested that with 19 July2005, and it worked. But the strtotime()
    > function seems to return -1 for dates before the UNIX epoch. How can I
    > convert these dates?
    >[/color]


    Comment

    • Michel

      #3
      Re: Timestamps for 1800's

      don't double post. crosspost please

      Mich

      "DJ Craig" <spit@djtriciti es.com> wrote in message
      news:1121869645 .273644.174560@ o13g2000cwo.goo glegroups.com.. .[color=blue]
      > I'm trying to convert this date:
      > 12 May1868
      > Into this:
      > 18690512
      > That's YYYYMMDD. So first I need to convert it to a UNIX time stamp
      > using the strtotime() function, then convert it to YYYYMMDD. This
      > works for more rescent dates:
      > $d = date('Ymd', strtotime($d));
      > I tested that with 19 July2005, and it worked. But the strtotime()
      > function seems to return -1 for dates before the UNIX epoch. How can I
      > convert these dates?
      >[/color]


      Comment

      • DJ Craig

        #4
        Re: Timestamps for 1800's

        Thanks for the help. How do you crosspost with Google Groups?

        Comment

        • Colin McKinnon

          #5
          Re: Timestamps for 1800's

          DJ Craig spilled the following:
          [color=blue]
          > I'm trying to convert this date:
          > 12 May1868
          > Into this:
          > 18690512
          > That's YYYYMMDD. So first I need to convert it to a UNIX time stamp
          > using the strtotime() function, then convert it to YYYYMMDD. This
          > works for more rescent dates:
          > $d = date('Ymd', strtotime($d));
          > I tested that with 19 July2005, and it worked. But the strtotime()
          > function seems to return -1 for dates before the UNIX epoch. How can I
          > convert these dates?[/color]

          32bit Unix time only works from 1970 to 2036 (ish)

          C.

          Comment

          • Daniel Tryba

            #6
            Re: Timestamps for 1800's

            Michel <no@spam.please > wrote:[color=blue]
            > don't double post. crosspost please
            >
            > Mich
            >
            > "DJ Craig" <spit@djtriciti es.com> wrote in message[/color]
            [snip 15 lines]

            And in other good advice to be found elsewhere: don't TOFU
            instead keep it readable please.

            Comment

            Working...