Parsing “date” field of iPhone SMS file from backup

后端 未结 8 1509
感动是毒
感动是毒 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:12

    Since date in mac is calculated from 2001 and not 1970, we have to add some extra to this mac date.

    978307200000 is equivalent to milliseconds until 2001-01-01

    Also multiplying by 1000 is required to convert to milli-seconds.

    macDate * 1000 + 978307200000
    
    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题