How to convert date to Unix timestamp (epoch) in JavaScript

1 Answer

0 votes
const date = new Date("April 1, 2022 03:21:44"); 
const epoch = date.getTime() / 1000.0;
 
console.log(epoch);
 
  
   
  
/*
run:
  
1648772504
  
*/

 



answered Mar 31, 2022 by avibootz

Related questions

1 answer 159 views
1 answer 161 views
1 answer 122 views
1 answer 138 views
1 answer 158 views
1 answer 158 views
3 answers 235 views
...