How to get ISO date without the milliseconds in Node.js

2 Answers

0 votes
const date = new Date();
 
const ISOwithoutMs = date.toISOString().split('.')[0] + 'Z';
 
console.log(ISOwithoutMs); 
 
  
    
    
    
    
/*
run:
    
2022-04-03T15:21:02Z
    
*/

 



answered Apr 3, 2022 by avibootz
0 votes
const ISOdate = '2022-01-24T12:14:30.135Z';
 
const ISOdateWithoutMs = ISOdate.split('.')[0] + 'Z';
 
console.log(ISOdateWithoutMs); 
 
  
    
    
    
    
/*
run:
    
2022-01-24T12:14:30Z
    
*/

 



answered Apr 3, 2022 by avibootz

Related questions

2 answers 144 views
2 answers 171 views
2 answers 164 views
1 answer 172 views
1 answer 163 views
1 answer 98 views
...