Unix epoch là số giây từ 00:00:00 UTC ngày 1/1/1970. JavaScript dùng milliseconds.
Để lấy milliseconds hiện tại:
var milliseconds = (new Date).getTime();
// hoặc ES6+
const milliseconds = Date.now();
Date.now() nhanh hơn, không tạo đối tượng Date trung gian. Trả về number milliseconds.
Chuyển sang giây (Unix timestamp): Math.floor(Date.now() / 1000)