If brevity is in order, then:
function secondsSinceEpoch() { return new Date/1000 | 0; }
Where:
new Date equivalent to new Date()| 0 | 0 truncates the decimal part of the result and is equivalent to Math.floor(new Date/1000) (see What does | 0 do in javascript ).
Using new functions and allowing you to pass the date to a function, the code can be reduced to:
let getSecondsSinceEpoch = (x = new Date) => x/1000 | 0;
But I prefer function declarations, because I think they are clearer.
source share