Ads by ProfitSence
Close

How to Format a JavaScript date ?

Last Updated on Wednesday 5th Oct 2022

javascript format date

			
					var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

			
	

Lots of methods that will generate a string representing that date.

			
					console.log(today.toLocaleDateString("en-US")); // 6/25/2021
console.log(today.toLocaleDateString("en-US", options)); // Friday, June 25, 2021

			
	
			
					console.log(new Date().toISOString().slice(0, 10));
// 2021-06-25

			
	

javascript date format

toDateString: Implementation dependent, show only the date.

			
					new Date().toDateString() // Fri Jun 25 2021

			
	

toISOString: Show ISO 8601 date and time.

			
					new Date().toISOString() // 2021-06-25T13:49:53.462Z

			
	

toJSON: Stringifier for JSON.

			
					new Date().toJSON() // 2021-06-25T13:50:38.233Z

			
	

toLocaleString: Implementation dependent, a date&time in locale format.

			
					new Date().toLocaleString() // 6/25/2021, 7:21:41 PM