How to format date and time using timezone in JavaScript

1 Answer

0 votes
const dateFormat = {
			timeZone:"Canada/Central",
      hour:  "2-digit",
      minute: "2-digit",
      second: "2-digit"
};

const date = new Date().toLocaleDateString("en-US", dateFormat);


console.log(date);

  
    
    
/*
run:
    
"5/26/2021, 2:35:33 AM"
    
*/

 



answered May 26, 2021 by avibootz

Related questions

1 answer 151 views
3 answers 229 views
1 answer 190 views
2 answers 166 views
3 answers 252 views
1 answer 217 views
...