To convert the current date and time to a UNIX timestamp do the following:
var ts = Math.round((new Date()).getTime() / 1000);
getTime() returns milliseconds from the UNIX epoch, so divide it by 1000 to get the seconds representation. It is rounded using Math.round() to make it a whole number. The "ts" variable now has the UNIX timestamp for the current date and time relevent to the user’s web browser.