Convert Javascript Date object to Filetime

1.7k Views Asked by At

Can't believe I'm unable to find the very simple case of converting a Javascript date object to Filetime.
The other way around popped up a lot while searching.

I have provided the solution below for anyone else who is looking for it.

1

There are 1 best solutions below

0
GusOst On BEST ANSWER

To convert now to Filetime:

function filetimeFromDate(date) {  
    return date.getTime() * 1e4 + 116444736e9;
}
const now = new Date();
const filetimeNow = filetimeFromDate(now);
console.log(filetimeNow);