I tried below.
var unixtime = new Date / 1000;
then, compilation error occured.
error TS2113: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
How to get unixtime with no compilation error ?
Use the +
operator to explicitly convert to a number:
var x = +new Date / 1000;
Or just use the faster / clearer method Date#now
:
var x = Date.now() / 1000;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With