Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,900 questions

51,831 answers

573 users

How to convert a date to milliseconds in Node.js

3 Answers

0 votes
console.log(Date.parse("2022-01-23"));
 
 

 
/*
run:
    
1642896000000
 
*/

 



answered Jan 29, 2022 by avibootz
0 votes
const date = new Date("2022-01-19");
  
console.log(date.valueOf()); 
 
 


 
/*
run:
    
1642550400000
 
*/

 



answered Jan 29, 2022 by avibootz
0 votes
const d = new Date();
console.log(d.toString());
 
// milliseconds from midnight of January 1, 1970
const milliseconds = d.getTime();
 
console.log(milliseconds);
  
  
  
  
/*
run:
  
Sat Jan 29 2022 09:04:57 GMT+0000 (Coordinated Universal Time)
1643447097971
  
*/

 



answered Jan 29, 2022 by avibootz

Related questions

1 answer 133 views
1 answer 78 views
2 answers 141 views
2 answers 152 views
1 answer 118 views
...