Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Date getTime() code snippet with mysterious additional characters

<script language="JavaScript">
var t = new Date();
t.getTime() + -864e5;
</script>

What is that funky code after the "+" at the end of the second line doing?

It is probably made to be hard to understand, since I suspect it's one of the ways they try to protect themselves against scraping.

like image 709
Mattis Avatar asked Aug 21 '13 13:08

Mattis


People also ask

What does Date getTime () do?

Javascript date getTime() method returns the numeric value corresponding to the time for the specified date according to universal time. The value returned by the getTime method is the number of milliseconds since 1 January 1970 00:00:00. You can use this method to help assign a date and time to another Date object.

What is 864e5?

864e5 is a valid JavaScript number that represents the number of milliseconds (a millisecond is 1/1000'th of a second) in a 24 hour day. 1000*60*60*24 = 86400000 or using exponential notation 864e5.

What does getTime return Date?

JavaScript Date getTime() getTime() returns the number of milliseconds since January 1, 1970 00:00:00.


2 Answers

It is a valid JavaScript number that represents the number of milliseconds in a 24 hour day.

1000*60*60*24 or 86400000 or 864e5
like image 152
cocco Avatar answered Oct 25 '22 08:10

cocco


-864e5 means "minus 1 day". So the JavaScript is really getting the date/time 24 hours ago.

like image 45
mynetx Avatar answered Oct 25 '22 07:10

mynetx