Skip to content
Advertisements

JavaScript Date.getTime()

Why getTime ?

The JavaScript getTime () method returns the number of milliseconds from January 1, 1970 (midnight (hour: 00.00)) to the specified date.

Syntax:

Date.getTime()

return: A Number, representing the number of milliseconds since midnight January 1, 1970


JavaScript getTime Examples

Example 1

With the JavaScript getTime () method, we can find the seconds from 1970 to the present.

        var now = new Date();
        console.log(now.getTime());

1549481101927


Example 2

With the getTime () method from JavaScript, we can find the seconds from 1970 to the specified date.

        var date = new Date('April 21, 1983 22:47:55');
        console.log(date.getTime());

419798875000


Example 3

        var date = new Date('October 21, 1983 ');
        console.log(date.getTime());

435531600000


Browser Support

Chromeyes
Edgeyes
Firefox1
Internet Exploreryes
Operayes
Safariyes
Android webviewyes
Chrome for Androidyes
Edge mobileyes
Firefox for Android4
Opera Androidyes
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: