0

https://m.facebook.com/friends/center/requests/outgoing/#friends_center_main enter image description here

Hello, I am coding a chrome extension that will cancel friend requests sent on Facebook after a certain date. The problem is that Facebook writes the request dates in minutes, days, months, years etc. It is not possible to detect them perfectly on the plugin.

<abbr data-store="{&quot;time&quot;:1642405814,&quot;short&quot;:true,&quot;forceseconds&quot;:false}" data-sigil="timestamp" data-store-id="0">3 ay</abbr>

The dates are given as attributes in json format as below, but I could not find how to process this date. {"time":1642405814,"short":true,"forceseconds":false}

console.log(new Date(1642405814))

If I want to use new date directly as above, the year is 1970, but the request was sent a few months ago. It is outputting the wrong date.

 console.log(new Date(Date.now() - new Date(1642405814)))

Although I converted it as above, it shows that it is 1 month, but 3 months have passed since the request. I can't figure out how to set this date. Can you please help?

i3 kafa
  • 15
  • 1
  • 5
  • 1
    Just add three zeros of a millisecond to the end of the time `console.log(new Date(1642405814000))` – Aissaoui Ahmed Apr 02 '22 at 12:24
  • It worked thank you very much. I couldn't solve it anyway. You have been of great help to me. – i3 kafa Apr 02 '22 at 12:26
  • The vote button is not active for me. I can accept the answer if you can post it as a regular answer. You saved me from a huge burden. – i3 kafa Apr 03 '22 at 11:50

1 Answers1

2

Just add three zeros of a millisecond to the end of the time

console.log(new Date(1642405814000))
Aissaoui Ahmed
  • 258
  • 2
  • 10