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 146 views
1 answer 143 views
1 answer 112 views
1 answer 125 views
1 answer 147 views
1 answer 145 views
3 answers 220 views
...