Alright when I do the code:
You get the Unix t
If you don't need (millisecond) presision, then just divide & Math.floor the javascript's function. So:
time();
and
Math.floor((new Date).getTime()/1000)
should return the same value at the same time.