How to get ISO date without the milliseconds in TypeScript

2 Answers

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

 



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

...