formatDate(date/timestamp [, formatString] [, culture])

Formats date/timestamp according to the given formatString(optional) & culture(optional). Default formatString is “DD MMM YYYY” & default culture is “en”.

  • This is a static function under CanvasJS namespace and hence it can be used directly without instantiating a chart. Hence you can also use it outside the chart too for formatting date.
  • Can be very useful inside Custom Formatter Functions

//Using CanvasJS.formatDate.
var  chart =  new  CanvasJS.Chart("container",
		text: "Sales data for " + CanvasJS.formatDate(new Date(2012, 06, 13)) //gets formatted as 13 Jul 2012

To know more about date format string , please refer to this section.

To know more about adding custom culture, info please refer to this section

Try it Yourself by Editing the Code below.

If you have any questions, please feel free to ask in our forums.Ask Question