JavaScript Date Format: Guide
Creation
First of all you'll have to create a DateFormat object1).
There are three ways to to this:
new DateFormat()Constructs an empty DateFormat object. you'll have to parameterize it later to get something useful out of it.new DateFormat(dateStyle, timeStyle, locale)This form of the constructor function is the one you'll probably use most of the time. It accepts two numeric arguments that indicate if you want no, a short, medium, long or fully formatted date or time respectively. Additionally you can specify a locale object or name if you are not happy with the default locale. see also what the Reference says about Locales and maybe you're interested in Customizing the script.new DateFormat(pattern)You'll want to use this, when you are not satisfied with one of the predefined styles available through the second variant of the constructor. Here you can specify a custom formatting pattern that should fullfill all your requirements. See the Reference for a specification of it's syntax.
Usage
Now that you have the desired object your're ready to use it, which is extremly simple as you'll see in the next section. Just call the format method and pass it the JavaScript Date Object you want to format.
Localization
There are 7 predefined Locales: German, Austrian German, US English, British English, French, Spanish and Portugese.
Each of these is represented by an instance of a Locale object, which provides translations of day of week, month, era and AM/PM marker (if any) names as well as the locale specific format strings.
You can easily add such locales (or remove some if you want to save space). See Customizing the script for a detailed description of how to add remove and modify Locales.
Once you create a new Locale object, it is added to the Locale.availableLocales collection, where it is accessible by it's name (which you passed to the constructor function).
Back to Date Format
new operator, if you don't know how this works, you'll have to read some newbie guide on JavaScript first - I hope I'll be able to provide one in the near future