Javascript date toLocaleFormat() method converts a date to a string using the specified formatting.

Note: This method may not work in all the browsers like IE.