In plain JavaScript and TypeScript we can write the following to obtain the unix timestamp of a Date:
let d = new Date();
const unixtime = d.valueOf();
Now, in JavaScript, we can easily convert that unix timestamp back to a Date:
d = new Date(unixtime);
However, in TypeScript, the above returns an error message:
error TS2554: Expected 0 arguments, but got 1.
So how can I convert a unix timestamp to a date in TypeScript? I'm using ES6 library
in TypeScript, the above returns an error message:
There is no error in current TypeScript:
Update TypeScript to latest 🌹
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