Parsing “date” field of iPhone SMS file from backup

后端 未结 8 1508
感动是毒
感动是毒 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 00:47

    Since the backup is exported to SQLite database format, here's how to convert the number to a real date in SQLite:

    select
        datetime(date + strftime('%s', '2001-01-01 00:00:00'),
           'unixepoch', 'localtime') as date,
        *
    from message
    
    0 讨论(0)
  • 2021-02-02 00:47

    It is in seconds since 1/1/2001 instead of the others which are Unix based off of 1/1/1970. So to convert it to say an Excel time your formula would be =Cell/(60*60*24) + "1/1/2001".

    0 讨论(0)
  • 2021-02-02 00:50

    Fomurla with time of messages: =Cell/(60*60*24) + "1/1/2001 7:00"

    0 讨论(0)
  • 2021-02-02 00:55

    There may be another answer.

    =Cell/(60*60*24) + "1/1/1970"

    works with my current version of the iPhone/iOS => 4.3.3

    0 讨论(0)
  • 2021-02-02 01:04

    I don't know about getting the correct date given two versions present, but when I did this today, I noticed the date column was not the standard unix time but a longer number with seemingly nine zeros at the end, like 444548608000000000. This is what I did to get the correct date:

    select
        datetime(substr(date, 1, 9) + 978307200, 'unixepoch', 'localtime') as f_date,
        text
    from message
    
    0 讨论(0)
  • 2021-02-02 01:06

    Bohemian♦ is right, but there's a little typo in his answer:

    use %S (capitals) instead of %s, since the time is represented in seconds since 2001 and not 1970!

    Doc from https://www.sqlite.org/lang_datefunc.html

    %s      seconds since 1970-01-01
    %S      seconds: 00-59
    

    select datetime(date + strftime('%S', '2001-01-01 00:00:00'), 'unixepoch', 'localtime') as date, * from message

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