I have Time value like this :
const timeValue = new Date('2023-06-13T12:34:56.789123Z');
I need to convert this data to Unix Timestamp with Microseconds precisions, but method Date.getTime()
only support Millisecond. What should I do to solve this issue?
2
Answers
You can use this package: https://www.npmjs.com/package/microseconds if you are using node.
It uses
process.hrtime()
orperformance.now()
if available. You can also do this yourself by using these functions but the package already does the necessary calculations. Be aware, that both these possible functions may not be available sometimes. In these cases, the package will simply fall back toDate.now()*1000
.