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 156 views
1 answer 152 views
1 answer 120 views
1 answer 131 views
1 answer 153 views
1 answer 152 views
3 answers 224 views
...