Essential Chart supports formatting labels in an axis using labelFormat property of axis. This property takes a format string as value based on the value type of axis. You can display the date values in the date time axis in date, month, year, time, date/month/year, etc., formats using labelFormat property.
By default, Chart automatically formats the axis labels smartly, based on the calculated minimum and maximum values of data points. You can also specify the desired format to the labels using labelFormat property. The following code example illustrates this.
The following screenshot displays the Chart with primary X axis in “MMM dd, yyyy” format.
Figure 1: Chart with primary X axis in “MMM dd, yyyy” format
JS Playground sample link: Datetime Labels Formatting
Date Time formats
The following table illustrates the various date time formats for axis labels.
Label Format Value
Displays the name of the month and numeric date.
Displays the month in two digits from 01 to 12.
Displays three letters of the month name.
Displays the name of the month.
Displays the day of the month from 01 to 31.
Displays the first three letters of the day.
Displays the name of the day.
Displays the last two digits of the year.
Displays the four digits of year.
Displays the short time. (hour and minutes)
Displays AM or PM.
Displays long time. (hour, minutes and seconds)
Displays the hour of the day in 12-hour format.
Displays the minute from 00 to 59.
Displays the seconds from 00 to 59.
Displays the period or era.
Displays the difference between UTC and current time zone.
Thursday, January 01, 2015 12:00 AM
Displays the long date and short time.
Thursday, January 01, 2015 12:00:00 AM
Displays the long date and long time.