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 246 views
1 answer 258 views
1 answer 216 views
1 answer 238 views
1 answer 251 views
1 answer 254 views
3 answers 403 views
...