Този сайт ще има ограничена функционалност, докато се извършва тече неговата поддръжка. Ако дадена статия не може реши проблема ви и искате да зададете въпрос, нашата общност е готова да ви помогне на @firefox в Twitter и /r/firefox в Reddit.

Търсене в помощните статии

Избягвайте измамите при поддръжката. Никога няма да ви помолим да се обадите или изпратите SMS на телефонен номер или да споделите лична информация. Моля, докладвайте подозрителна активност на "Докладване за злоупотреба".

Научете повече

When reading JSON formated backup my bookmarks, In what format are the lastModifed and dateAdded proporties?

  • 6 отговора
  • 1 има този проблем
  • 9 изгледи
  • Последен отговор от cor-el

more options

I would like to analyze my bookmarks using python. I can't figure out the format of the lastModifed and dateAdded fields. There are too many digits for a unix time stamp. When I truncate the number to the first 10 digits and use pythons datetime.fromtimestamp I get dates that don't make any sense. Any help would be greatly appreciated.

I would like to analyze my bookmarks using python. I can't figure out the format of the lastModifed and dateAdded fields. There are too many digits for a unix time stamp. When I truncate the number to the first 10 digits and use pythons datetime.fromtimestamp I get dates that don't make any sense. Any help would be greatly appreciated.

Избрано решение

this is what I'm doing that seems to work. from JSON bookmark file: "dateAdded": 1285530321809000,

python 3 code I'm using after truncating the last 6 digits: datetime.datetime.fromtimestamp(1285530321).strftime('%Y-%m-%d %H:%M:%S')

Result: >>> '2010-09-26 15:45:21'

Прочетете този отговор в контекста 👍 0

Всички отговори (6)

more options

Those date stamps are in microseconds, so you would have to remove the last three digits or divide the number by 1000 if your software expects milliseconds or six digits for seconds.

The date and time is saved in 64 bit EPOCH format in micro seconds.

Променено на от cor-el

more options

I'm not certain where the discrepancy is but all the numbers in the fields are 16 digit numbers. Dividing by 1000 or dropping the last 3 digits still leaves an integer which is too large. Before I ask the question I tried converting the timestamps using what I thought was the first 10 digits but it turned out I used 11 and it was giving me dates far in the future. So, if I use the first 10 digits it gives me dates that make sense. It seems to me that the last 3 digits (all zeros) must be padding to fill 64 bits. Anyway the problem seems to be solved. Thank you for the help and the info.

more options

Does this converter work on those dates: http://www.esqsoft.com/javascript_examples/date-to-epoch.htm (Option 2)

more options

You didn't answer that time format your software is using.

JavaScript uses millisecond resolution.

If dividing by 1E3 still gives a date in the future for you then it is likely that seconds are used in your case and you would have to divide by 1E6 instead of 1E3

more options

Избрано решение

this is what I'm doing that seems to work. from JSON bookmark file: "dateAdded": 1285530321809000,

python 3 code I'm using after truncating the last 6 digits: datetime.datetime.fromtimestamp(1285530321).strftime('%Y-%m-%d %H:%M:%S')

Result: >>> '2010-09-26 15:45:21'

more options

Yes, that is the date-time in Unix Epoch format in seconds.