Datum < 1970 nach Timestamp

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Datum < 1970 nach Timestamp

    Kennt jemand eine einfache möglichkeit ein Datum das vor dem 01.01.1970 liegt in einen UNIX-Timestamp umzuwandeln.

    Mit mktime oder strtotime kommt immer -1 als Ergebnis.

    Danke im Voraus
    mtm

  • #2
    aus den UCN auf
    http://de3.php.net/manual/de/function.mktime.php
    OK, so in trying to get a date of birth on 4-10-1955 to end up in a Windows type date, 20189 (num days since 1900), I need to figure out how to make mktime() go back to 1900 to get the number of days to this goobers DOB. Well, as indicated by everyone, you cannot get mktime() to go back that far. So, the number of days from 1-1-1900 to 1-1-1970 is 25,550 + 18 leap years = 25,568. So, to get the number of days from 1-1-1900 to 4-10-1955, do this:

    $numDaysSince1900 = ceil(mktime(0,0,0,4,10,1955)/(60*60*24))+25568;

    So, we got the number of seconds from 4-10-1955 until 1-1-1970 (negative), divide by the number of seconds*minutes*hours to get it into days, then add this number to the number of days from 1955-1970. It was a decimal for some reason that seemed to work out correctly if I rounded up:ceil().

    Don't even ask how long it took me to do this. I'm not sure I want to know if I am a moron, and there is an easier way to do it.
    Kissolino.com

    Kommentar

    Lädt...
    X