Another Auto Update Script

By sizzlemctwizzle Last update Feb 11, 2011 — Installed 15,480 times.

Confused about time value

in
Subscribe to Confused about time value 2 posts, 2 voices



iaindalton User

CheckScriptForUpdate = {
...
 time: new Date().getTime() | 0,
...
}

Why do you bitwise-or the number of milliseconds since 1970-01-01 00:00:00 with 0? I fooled around at the JS console and got this:

js> var time = new Date().getTime();
js> time
1242371790835
js> time | 0
1126242291

What does it mean? I don't glark it from context either.

 
sizzlemctwizzle Script's Author

It truncates the time to an integer so that I can store it as one. I use to store it as a string but if done consistently I think the current way produces the desired result. I could do the same with:

time>>0
~~time
You can read up on obscure operator usage here: http://www.merlyn.demon.co.uk/js-logic.htm#OC

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel