Pregunta

<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.

¿Fue útil?

Solución

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

Otros consejos

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

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

It looks like the + -864e5 is offsetting the time 1 day into the past.

Its true its not very readable, or makes much sense to people looking at it for a first time, but there isn't really any other way in bare js (at this point).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top