Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the timestamp of loaded page

Is there a way in javascript or in chrome extension API to instantly (without saving the timestamp during the loading time) get the timestamp of when the DOM of the page was loaded in Chrome?

like image 225
Le_Coeur Avatar asked Feb 28 '14 14:02

Le_Coeur


People also ask

How do I get a timeStamp from a date?

Getting the Current Time Stamp If you instead want to get the current time stamp, you can create a new Date object and use the getTime() method. const currentDate = new Date(); const timestamp = currentDate. getTime(); In JavaScript, a time stamp is the number of milliseconds that have passed since January 1, 1970.

Can you see what time you opened a tab Chrome?

Just check the time the page was last loaded using Chrome's History page, if it was enabled and not cleared ( Menu > History and recent tabs > History , ctrl+H or about:history ).

What is event timeStamp?

timeStamp. The timeStamp read-only property of the Event interface returns the time (in milliseconds) at which the event was created.

What is a timeStamp in JavaScript?

In javascript, the timestamp is one of the formats that can be achieved with the help of some default methods like Date() instance by using this date object it retrieves the date and also holds the time in the readable formats we can create the new object by using Date() method also it includes the timestamps it shows ...


1 Answers

You can use the performance.timing object (implemented by all modern browsers, except Safari) to get all kinds of different timestamps.

You need to see for yourself what timestamp would be most appropriate for you. "when the page was loaded" is quite a vague description. Otherwise, be more specific.

If you don't to go through the trouble of having a Chrome content script communicate with a Chrome background page, you can also use the Chrome webNavigation API. However this only exposes events, so you'd be responsible for saving the time when this event is fired (for each page).

like image 51
Myrne Stol Avatar answered Oct 04 '22 15:10

Myrne Stol