Parsing “date” field of iPhone SMS file from backup

后端 未结 8 1510
感动是毒
感动是毒 2021-02-02 00:26

While this isn\'t a programming question per se, it IS related.

So I\'m trying to figure out how to parse the SMS DB that gets backed up from the iPhone. I\'m looking at

8条回答
  •  后悔当初
    2021-02-02 01:13

    Apple uses Mac Absolute Time (MacTime). This is counted from 01-01-2001. The other timestamp you see is UnixTime. This starts from 01-01-1970.

    You have to add 31 years to MacTime to get UnixTime. This is a PHP-snippit:

    $macTime = $d['ZMESSAGEDATE']; // MacTime column (from Whatsapp)
    $unixTime =  $macTime + 978307200;
    echo date("Y-m-d H:i:s", $unixTime);
    

    The time difference is calculated using this website: https://www.timeanddate.com/date/durationresult.html?d1=1&m1=1&y1=1970&d2=1&m2=1&y2=2001&h1=0&i1=0&s1=0&h2=0&i2=0&s2=0

提交回复
热议问题