JavaScript
HTML
CSS
jQuery
PHP
SQL
WordPress
JavaScript Reference

Quick Reference

The Date toLocaleString() method returns a date and time as a string, using locale settings.

				
					<!-- html element to place output -->
<p id="my_output"></p>
				
			
				
					// variable
let my_date = new Date();

// set date
let text = my_date.toLocaleString();

// output to the HTML element
document.getElementById('my_output').innerHTML = text;
				
			

Output

				
					8/22/2022, 4:54:31 PM
				
			

Syntax

				
					Date.toLocaleString(locales, options)
				
			

Parameters

ValueDescription
locales
  • ar-SA Arabic
  • bn-BD Bangla
  • bn-IN Bangla
  • cs-CZ Czech
  • da-DK Danish
  • de-AT Austrian German
  • de-CH "Swiss" German
  • de-DE Standard German
  • el-GR Modern Greek
  • en-AU Australian English
  • en-CA Canadian English
  • en-GB British English
  • en-IE Irish English
  • en-IN Indian English
  • en-NZ New Zealand English
  • en-US US English
  • en-ZA English (South Africa)
  • es-AR Argentine Spanish
  • es-CL Chilean Spanish
  • es-CO Colombian Spanish
  • es-ES Castilian Spanish (as spoken in Central-Northern Spain)
  • es-MX Mexican Spanish
  • es-US American Spanish
  • fi-FI Finnish
  • fr-BE Belgian French
  • fr-CA Canadian French
  • fr-CH "Swiss" French
  • fr-FR Standard French
  • he-IL Hebrew
  • hi-IN Hindi
  • hu-HU Hungarian
  • id-ID Indonesian
  • it-CH "Swiss" Italian
  • it-IT Standard Italian
  • ja-JP Japanese
  • ko-KR Korean (Republic of Korea)
  • nl-BE Belgian Dutch
  • nl-NL Standard Dutch
  • no-NO Norwegian
  • pl-PL Polish
  • pt-BR Brazilian Portuguese
  • pt-PT European Portuguese (Portugal)
  • ro-RO Romanian
  • ru-RU Russian
  • sk-SK Slovak
  • sv-SE Swedish
  • ta-IN Indian Tamil
  • ta-LK Sri Lankan Tamil
  • th-TH Thai
  • tr-TR Turkish
  • zh-CN Mainland China (simplified characters)
  • zh-HK Hong Kong (traditional characters)
  • zh-TW Taiwan (traditional characters)
optionsdateStyle:
  • "full"
  • "long"
  • "medium"
  • "short"
timeStyle:
  • "full"
  • "long"
  • "medium"
  • "short"
localeMatcher:
  • "best-fit" (default)
  • "lookup"
timeZone -

hour12:
  • false
  • true
hourCycle:
  • "h11"
  • "h12"
  • "h23"
  • "h24"
formatMatcher:
  • "basic"
  • "best-fit"
weekday:
  • "long"
  • "short"
  • "narrow"
year:
  • "2-digit"
  • "numeric"
month:
  • "2-digit"
  • "long"
  • "narrow"
  • "numeric"
  • "short"
day:
  • "2-digit"
  • "numeric"
hour:
  • "2-digit"
  • "numeric"
minute:
  • "2-digit"
  • "numeric"
second:
  • "2-digit"
  • "numeric"
timeZoneName:
  • "long"
  • "short"

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

JavaScript
HTML
CSS
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.