Date Time Formatting

Overview

AnyChart Stock shows data that is based on date time values. In any element that displays some data point or range, or series legend - you will most likely show some date time value.

The display of any date time values in all elements of the chart, AnyChart Stock uses very powerful uniform formatting mechanism, which allows to display date and time almost in any possible representation.

Here is a short list of formatting features:

This article describes almost everything you need to know to format any Date Time values in any element of AnyChart Stock.

Please read the following: This document describes in-depth all you need to know about tokens and formatting, but we want to note that there is a very handy utility that may help you to build desired formatting patterns, this is Localization and Date-Time Utility, please read about it, launch it and play with it as you read this article - the utility is a real time saver, when you need to create date time formatting pattern - for it either contains lots of presets and can be used as the tester for your custom patterns.

to top

Applicability Places

There are a number of chart elements, where you can use date time formatting. Illustration below highlights these elements:

And the table below describes them, please follow the link in the second column to learn more about specific element:

# Element Configuration Tutorial
Legend: Title label Legend: Title and Date-Time Labels
X-Axis: Line marker X-Axis: Line Markers
Separated tooltip text Separated Tooltips Text Configurations
Legend: Date-time label Legend: Title and Date-Time Labels
Event-Marker tooltip Event-Markers: Internal Tooltips
Grouped tooltip title Grouped Tooltips Text Configuration

X-Axis: Major and Minor labels

X-Axis: Major and Minor labels
X-Axis: Date highlighter X-Axis: Date Highlighter
X-Axis: Range Marker X-Axis: Range Markers
Scroller Label Scroller Labels and Grid Settings
Range picker edit-boxes Range Picker

to top

Formatting String

The way you create formatting string doesn't depend on the element: this is a special string that uses tokens available in the elements formatting along with date time formatting tokens that specify how exactly date time should be shown.

Note that you can show identical values in different ways, specifying different formatting options. Table below shows how formatting string can alter the way the same timestamp is presented:

Format Timestamp Result
%M/%d/%yyyy 2010-04-13 17:18:45 4/13/2009
%M/%d/%yyyy %h:%mm %tt 2010-04-13 17:18:45 4/13/2009 5:18 PM
%dd.%MM.%yyyy %H:%mm:%ss 2010-04-13 17:18:45 13.04.2009 17:18:45
%hh:%mm %tt 2010-04-13 17:18:45 05:18 PM
%dddd, %MMMM %dd %yyyy 2010-04-13 17:18:45 Tuesday, April 13 2009
%yyyy年%M月%d日 2010-04-13 17:18:45 2010年4月13日

As you can see formatting string defines which parts of timestamp should be shown, how they should be shown and arranged.

%M, %d, %t and others are called date time formatting tokens and you can find full list of all available tokens at:

Besides tokens you can use any other symbols in formatting string, the only special symbol is percent sign - "%", and if you need to use it - you have to escape it with backslash: "\%".

You can either define specific format for each chat element or set global default, please follow these links to learn more:

to top

Tokens and Properties

Tokens are special keywords that can be used in formatting string to make component show some value that has something to do with the element. The illustration below tries to give visual explanation of this:

You can see that you can show start and end dates for ranges, current date for point tooltip or legend item, first and last date visible on the chart and so on - all these values are dynamic, and they may change when user moves a mouse or scrolls through the data.

to top

Syntax

Tokens are used in formatting string as follows: {%TOKEN_NAME}{"DATE_TIME_FORMAT"}, where:

If you want to use the default formatting - skip {"DATE_TIME_FORMAT"} part, and leave only the token: {%Date}.

Take a look at the tooltip configuration:

XML/JSON Syntax
Plain code
03     <format><![CDATA[Date Time: {%Date.Current}{"%M/%d/%yyyy %h:%mm:%ss %tt"}, of the point.]]></format>
04   </separated_tooltip>
01{
03    format: "Date Time: {%Date.Current}{\"%M/%d/%yyyy %h:%mm:%ss %tt\"}, of the point."
04  }
05}

You can see there is a formatting string in <format> node:

Now, let's examine dynamic part, it consists of two parts:

Table bellows shows how it would work for the given point:

Item Example
Point timestamp: 2009-01-12 23:35:10.000
Formatting String: Date Time: {%Date.Current}{"%M/%d/%yyyy %h:%mm:%ss %tt"}, of the point.
Actual text shown: Date Time: 1/12/2009 11:35:10 PM, of the point.

All tokens used in any formatting string obey the rules described above.

Tokens and Properties

The set of tokens and properties varies from element to element (but the formatting rules are uniform). In this section we will give a brief description of tokens in different elements and provide links for further reading:

1. Legend: Title and Date-Time label, Separated Tooltip Text, Grouped Tooltip Title.

In Legend Label, Legend Title, Separated tooltip or Grouped tooltip you can use {%Date} token. This token allows you to show different values, depending on the property. Table below lists these properties:

Property Description
{%Date.Current} Date time of the hovered point.
{%Date.First} Date time of the first point in the dataset.
{%Date.Last} Date time of the last point in the dataset.
{%Date.FirstVisible} Date time of the first point in the range shown.
{%Date.LastVisible} Date time of the last point in the range shown.

Illustration below shows these values on the chart:

Any property of %Date you can also specify properties used to work with Approximation data:

Sub Property Description
{%Date.*.GroupingIntervalFirst} Date time of the starting point of current Grouping Interval.
{%Date.*.GroupingIntervalLast} Date time of the end point of current Grouping Interval (consequent interval group starting point minus one millisecond).

"*" denotes any of property: Current, First, Last, FirstVisible or LastVisible.

This "sub-properties" may be useful, when you use approximation and grouping.

List below features links to the other documents that describe how {%Date} is used in different elements:

2. X-Axis Markers and X-Axis Date highlighter.

In X-Axis Markers and X-Axis Date highlighter you can use these tokens:

These tokens don't have any properties and used as is. You can learn how to use them at:

3. Event-Marker Tooltip.

In Event Markers internal tooltips you can use these tokens:

{%GroupedDate} token has two optional properties:

Sub Property Description
{%GroupedDate.GroupingIntervalFirst} Date time of the starting point of current Grouping Interval
{%GroupedDate.GroupingIntervalLast} Date time of the end point of current Grouping Interval (consequent interval starting point minus one millisecond).

You can learn how to use Event Markers tokens at:

to top

Global (Default) Date Time Format

If you don't want to set date time format for each element, you can set it globally and define how date looks like be default - without any special formatting applied.

Sample XML below shows how to set "%dddd, %M/%d/%yyyy %h:%mm:%ss %tt" formatting string to be default:

XML/JSON Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <stock xmlns="http://anychart.com/products/stock/schemas/1.9.0/schema.xsd">
03   <settings>
04     <display_locale>
05       <default_date_time_format>
06         <format><![CDATA[%dddd, %M/%d/%yyyy %h:%mm:%ss %tt]]></format>
07       </default_date_time_format>
08     </display_locale>
09   </settings>
10 </stock>
01{
02  settings: {
03    displayLocale: {
04      defaultDateTimeFormat: {
05        format: "%dddd, %M/%d/%yyyy %h:%mm:%ss %tt"
06      }
07    }
08  }
09}

And here is the live sample - note that legend, tooltip and event marker tooltip follow the default without any additional settings:

Live Sample:  Date-Time Formatting - Default Format

 

Caution: If any of the elements define its own formatting rules (e.g. {%Date}{"%yy-%M-%d"}) - default settings are disregarded. To see default settings token should be used without formatting specifiers: {%Date}.

to top

Date Time Formatting Tokens Table

The table below lists all available date time formatting tokens along with their description.

Token Description Examples Samples
%d Represents the day of the month as a number from 1 through 31.

A single-digit day is formatted without a leading zero.
Format string: "%d"

Timestamp: 6/15/2009 1:45:30 PM
Result: 15

Timestamp: 6/1/2009 1:45:30 PM
Result:
1
>>
%dd Represents the day of the month as a number from 01 through 31.

A single-digit day is formatted with a leading zero.
Format string: "%dd"

Timestamp: 6/1/2009 1:45:30 PM
Result: 01
Timestamp: 6/15/2009 1:45:30 PM
Result: 15

>>
%ddd Represents the abbreviated name of the day of the week.

Abbreviated name can be localized: see Weekday Localization.
Format string: "%ddd"

Timestamp: 6/15/2009 1:45:30 PM
Result: Mon
>>
%dddd Represents the full name of the day of the week.

Name can be localized: see Weekday Localization.
Format string: "%dddd"

Timestamp: 6/15/2009 1:45:30 PM
Result: Monday
>>
%w Represents week shortest name.

Name can be localized: see Weekday Localization.
Format string: "%w"

Timestamp: 6/15/2009 1:45:30 PM
Result: M

>>
%e Represents number of the week in the year. (1...53)

Depends on week numbering rule, see: Week Rule Localization.
Format string: "%e"

Timestamp: 01/02/2004 1.45:30 PM
Result: 1

>>
%ee Represents the number of the week in the year. (01...53).

Depends on week numbering rule, see: Week Rule Localization.
Format string: "%ee"

Timestamp: 01/02/2004 1.45:30 PM
Result: 01
>>
%M Represents the month as a number from 1 through 12.

A single-digit month is formatted without a leading zero.
Format string: "%M"

Timestamp: 01/01/2004 1.45:30 PM
Result: 1
>>
%MM Represents the month as a number from 01 through 12.

A single-digit month is formatted with a leading zero.
Format string: "%MM"

Timestamp: 01/01/2004 1.45:30 PM
Result: 01
>>
%MMM Represents the abbreviated name of the month.

Name can be localized, see: Month Names Localization.
Format string: "%MMM"

Timestamp: 6/15/2009 1:45:30 PM
Result: Jun
>>
%MMMM Represents the full name of the month.

Name can be localized, see: Month Names Localization.
Format string: "%MMMM"

Timestamp: 6/15/2009 1:45:30 PM
Result: June
>>
%MMMMM Represents the abbreviated genitive name of the month.

Name can be localized, see: Genitive Month Names Localization.\
Format string: "%MMMMM"
Locale: Russian

Timestamp: 1/15/2009 1:45:30 PM
Result: Ян-я
>>
%MMMMMM Represents the full genitive name of the month.

Name can be localized, see: Genitive Month Names Localization.
Format string: "%MMMMMM"
Locale: Russian

Timestamp: 6/15/2009 1:45:30 PM
Result: Июня
>>
%N Represents the shortest name of the month (one letter).

Name can be localized, see: Month Names Localization.
Format string: "%N"

Timestamp: 6/15/2009 1:45:30 PM
Result: J
>>
%y Represents the year as a one-digit or two-digit number.

If the year has more than two digits, only the two low-order digits appear in the result. If the first digit of a two-digit year begins with a zero (for example, 2006), the number is formatted without a leading zero.
Format string: "%y"

Timestamp: 1/1/1911 12:00:00 AM
Result: 11

Timestamp: 6/15/2009 1:45:30 PM
Result: 9
>>
%yy Represents the year as a two-digit number.

If the year has more than two digits, only the two low-order digits appear in the result. If the two-digit year has fewer than two significant digits, the number is padded with leading zeros to produce two digits.
Format string: "%yy"

Timestamp: 1/1/1911 12:00:00 AM
Result: 11

Timestamp: 6/15/2009 1:45:30 PM
Result: 09
>>
%yyyy Represents the year as a four-digit number. Format string: "%yyyy"

Timestamp: 1/1/1911 12:00:00 AM
Result: 1911

Timestamp: 6/15/2009 1:45:30 PM
Result: 2009
>>
%h Represents the hour as a number from 1 through 12; that is, the hour is represented by a 12-hour clock that counts the whole hours since midnight or noon.

A particular hour after midnight is indistinguishable from the same hour after noon. The hour is not rounded, and a single-digit hour is formatted without a leading zero. For example, given a time of 4:12 in the morning or afternoon, this custom format specifier displays "4".
Format string: "%h"

Timestamp: 6/15/2009 1:45:30 AM
Result: 1

Timestamp: 6/15/2009 1:45:30 PM
Result: 1
>>
%hh Represents the hour as a number from 01 through 12; that is, the hour is represented by a 12-hour clock that counts the whole hours since midnight or noon.

A particular hour after midnight is indistinguishable from the same hour after noon. The hour is not rounded, and a single-digit hour is formatted with a leading zero. For example, given a time of 4:12 in the morning or afternoon, this format specifier displays "04".
Format string: "%hh"

Timestamp: 6/15/2009 1:45:30 AM
Result: 01

Timestamp: 6/15/2009 1:45:30 PM
Result: 01
>>
%H Represents the hour as a number from 0 through 23; that is, the hour is represented by a zero-based 24-hour clock that counts the hours since midnight.

A single-digit hour is formatted without a leading zero.
Format string: "%H"

Timestamp: 6/15/2009 1:45:30 AM
Result: 1

Timestamp: 6/15/2009 1:45:30 PM
Result: 13
>>
%HH Represents the hour as a number from 00 through 23; that is, the hour is represented by a zero-based 24-hour clock that counts the hours since midnight.

A single-digit hour is formatted with a leading zero.
Format string: "%HH"

Timestamp: 6/15/2009 1:45:30 AM
Result: 01

Timestamp: 6/15/2009 1:45:30 PM
Result: 13
>>
%m Represents the minute as a number from 0 through 59. The minute represents whole minutes that have passed since the last hour.

A single-digit minute is formatted without a leading zero.
Format string: "%m"

Timestamp: 6/15/2009 1:01:00 AM
Result: 1

Timestamp: 6/15/2009 1:59:00 PM
Result: 59

>>
%mm Represents the minute as a number from 00 through 59. The minute represents whole minutes that have passed since the last hour.

A single-digit minute is formatted with a leading zero.
Format string: "%mm"

Timestamp: 6/15/2009 1:01:00 AM
Result: 01

Timestamp: 6/15/2009 1:59:00 PM
Result: 59

>>
%s Represents the seconds as a number from 0 through 59. The result represents whole seconds that have passed since the last minute.

A single-digit second is formatted without a leading zero.
Format string: "%s"

Timestamp: 6/15/2009 1:00:01 AM
Result: 1

Timestamp: 6/15/2009 1:00:59 PM
Result: 59

>>
%ss Represents the seconds as a number from 00 through 59. The result represents whole seconds that have passed since the last minute.

A single-digit second is formatted with a leading zero.
Format string: "%ss"

Timestamp: 6/15/2009 1:00:01 AM
Result: 01

Timestamp: 6/15/2009 1:00:59 PM
Result: 59
>>
%f Represents the most significant digit of the seconds fraction; that is, it represents the tenths of a second in a date and time value. Format string: "%f"

Timestamp: 6/15/2009 1:45:00.001 AM
Result: 0

Timestamp: 6/15/2009 1:45:00.159 PM
Result: 1

>>
%ff Represents the two most significant digits of the seconds fraction; that is, it represents the hundredths of a second in a date and time value. Format string: "%ff"

Timestamp: 6/15/2009 1:45:00.001 AM
Result: 00

Timestamp: 6/15/2009 1:45:00.159 PM
Result: 15
>>
%fff Represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value. Format string: "%fff"

Timestamp: 6/15/2009 1:45:00.001 AM
Result: 001

Timestamp: 6/15/2009 1:45:00.159 PM
Result: 159
>>
%t Represents the first character of the AM/PM designator.

Designators can be localized, see: AM/PM Designators Localization.
Format string: "%t"

Timestamp: 6/15/2009 1:45:30 PM
Result: P

Timestamp: 6/15/2009 1:45:30 AM
Result: A
>>
%tt Represents the entire AM/PM designator.

Designators can be localized, see: AM/PM Designators Localization.
Format string: "%tt"

Timestamp: 6/15/2009 1:45:30 PM
Result: PM

Timestamp: 6/15/2009 1:45:30 AM
Result: AM
>>
%c Represents the number of month third: 1, 2 or 3.
Format string: "%c"

Timestamp: 01/02/2004 00.00:00
Result: 1

>>
%C Represents the shortest name of the month third.

Abbreviated name can be localized, see: Thirds of Month Localization.
Format string: "%C"

Timestamp: 01/02/2004 00.00:00
Result: B
>>
%CC Represents short name of the month third.

Abbreviated name can be localized, see: Thirds of Month Localization.

Format string: "%CC"

Timestamp: 01/02/2004 00.00:00
Result: Beg

>>
%CCC Represents full name of the month third.

Name can be localized, see: Thirds of Month Localization.

Format string: "%CCC"

Timestamp: 01/02/2004 00.00:00
Result: Beginning

>>
%r Represents the number of semester: 1 or 2.
Format string: "%r"

Timestamp: 01/02/2004 00.00:00
Result: 1

>>
%R Represents the shortest name of semester.

Abbreviated name can be localized, see: Semester Localization.
Format string: "%R"

Timestamp: 01/02/2004 00.00:00
Result: H1
>>
%RR Represents short name of semester.

Abbreviated name can be localized, see: Semester Localization.

Format string: "%RR"

Timestamp: 01/02/2004 00.00:00
Result: Half 1

>>
%RRR Represents full name of semester.

Name can be localized, see: Semester Localization.

Format string: "%RRR"

Timestamp: 01/02/2004 00.00:00
Result: 1st Half

>>
%q Represents the number of the quarter: 1, 2, 3 or 4.
Format string: "%q"

Timestamp: 01/02/2004 00.00:00
Result: 1

>>
%Q Represents the shortest name of the quarter.

Abbreviated name can be localized, see: Quarters Localization.

Format string: "%Q" Timestamp: 01/02/2004 00.00:00
Result: Q1
>>
%QQ Represents short name of the quarter.

name can be localized, see: Quarters Localization.
Format string: "%QQ"

Timestamp: 01/02/2004 00.00:00
Result: Qtr 1
>>
%QQQ Represents full name of the quarter.

Name can be localized, see: Quarters Localization.
Format string: "%QQQ"

Timestamp: 01/02/2004 00.00:00
Result: 1st Quarter
>>
%u Represents the number of Seconds elapsed since midnight of January 1, 1970.
Format string: "%u"

Timestamp: 01/02/2004 00.00:02
Result: 1073001602

>>
%T Represents the number of Milliseconds elapsed since midnight of January 1, 1970.
Format string: "%u"

Timestamp: 01/02/2004 00.00:00.034
Result: 1073001600034

>>

to top

Formatting Tokens Explanation and Samples

This section shows and explains samples of most popular formats. These formats are divided in several section, in each you will find sample formatting, explanation and live samples.

12-hour clock format

The 12-hour clock is a time conversion convention in which the 24 hours of the day are divided into two periods called ante meridiem (a.m., Latin: "before mid day" English: "before noon") and post meridiem (p.m., Latin: "after mid day" English: "after noon"). Each period consists of 12 hours numbered 12 (acting as zero), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, and 11.

A good starting point to learn more about this format is:

These are tokens that can be used to parse timestamps in 12-hours format:

You can change %t and %tt (AM/PM Designators) tokens values. Learn how to do that at:

Table below shows sample formatting in 12-hour clock standard with minutes precision:

Timestamp %M/%d/%yyyy %h:%mm %tt %M/%d/%yyyy %hh:%mm %t
2010-04-05 00:00:00.000 4/5/2010 12:00 AM 4/5/2010 12:00 A
2010-04-05 01:35:00.000 4/5/2010 1:35 AM 4/5/2010 01:35 A
2010-04-05 16:00:00.000 4/5/2010 4:00 PM 4/5/2010 04:00 P
2010-04-05 17:30:00.000 4/5/2010 5:30 PM 4/5/2010 05:30 P
2010-04-05 23:15:00.000 4/5/2010 11:15 PM 4/5/2010 11:15 P

And the same with seconds precision:

Timestamp %M/%d/%yyyy %h:%mm:%ss %tt %M/%d/%yyyy %hh:%mm:%ss %t
2010-04-05 00:00:00.000 4/5/2010 12:00:00 AM 4/5/2010 12:00:00 A
2010-04-05 01:35:01.000 4/5/2010 1:35:01 AM 4/5/2010 01:35:01 A
2010-04-05 16:00:45.000 4/5/2010 4:00:45 PM 4/5/2010 04:00:45 P
2010-04-05 17:30:17.000 4/5/2010 5:30:17 PM 4/5/2010 05:30:17 P
2010-04-05 23:15:59.000 4/5/2010 11:15:59 PM 4/5/2010 11:15:59 P

Live sample shows the chart, where 12-hour clock formatting is used for various elements of the charts:

Live Sample:  Date-Time Formatting - 12 hours clock format

to top

24-hour clock format

The 24-hour clock is a convention of time keeping in which the day runs from midnight to midnight and is divided into 24 hours, indicated by the hours passed since midnight, from 0 to 23. This system is the most commonly used time notation in the world today.

You can learn more about 24-hours format at:

The following tokens are used for 24-hours format:

Table below shows sample formatting in 24-hour clock standard with minutes precision:

Timestamp %d.%M.%yyyy %H:%mm %d.%M.%yyyy %HH:%mm
2010-04-05 00:00:00.000 5.4.2010 0:00 5.4.2010 00:00
2010-04-05 01:35:00.000 5.4.2010 1:35 5.4.2010 01:35
2010-04-05 16:00:00.000 5.4.2010 16:00 5.4.2010 16:00
2010-04-05 17:30:00.000 5.4.2010 17:30 5.4.2010 17:30
2010-04-05 23:15:00.000 5.4.2010 23:15 5.4.2010 23:15

And the same with seconds precision:

Timestamp %dd.%MM.%yyyy %H:%mm:%ss %dd.%MM.%yyyy %HH:%mm:%ss
2010-04-05 00:00:09.000 05.04.2010 0:00:09 05.04.2010 00:00:09
2010-04-05 01:35:01.000 05.04.2010 1:35:01 05.04.2010 01:35:01
2010-04-05 16:00:45.000 05.04.2010 16:00:45 05.04.2010 16:00:45
2010-04-05 17:30:21.000 05.04.2010 17:30:21 05.04.2010 17:30:21
2010-04-05 23:15:59.000 05.04.2010 23:15:59 05.04.2010 23:15:59

Live sample shows the chart, where 24-hour clock formatting is used for various elements of the charts:

Live Sample:  Date-Time Formatting - 24 hours clock format

to top

Using Milliseconds

If you need to show data in tiny time interval you may need to show time with milliseconds precision. To do so you need the following tokens:

Table below shows sample formatting with milliseconds precision:

Timestamp %H:%mm:%ss.%f %H:%mm:%ss.%ff %H:%mm:%ss.%fff
2010-04-05 00:00:09.001 0:00:09.0 0:00:09.00 0:00:09.001
2010-04-05 01:35:01.012 1:35:01.0 1:35:01.01 01:35:01.012
2010-04-05 16:00:45.123 16:00:45.1 16:00:45.12 16:00:45.123

Live sample shows the chart, where milliseconds formatting is used for various elements of the charts:

Live Sample:  Date-Time Formatting - Milliseconds

to top

Month numbers and names

To show month part of the date you can use to types of tokens:

Names shown using %N, %MMM and %MMMM tokens can be redefined according to local standards. You can learn how to do that at:

Table below shows sample formatting that uses month formatting tokens:

Timestamp %yyyy-%M-%d %yyyy-%MM-%d %N%d, %yyyy %MMM %d, %yyyy %MMMM %d, %yyyy
2009-01-09 2009-1-9 2009-01-9 J9, 2009 Jan 9, 2009 January 9, 2009
2009-02-09 2009-2-9 2009-02-9 F9, 2009 Feb 9, 2009 February 9, 2009
2009-03-09 2009-3-9 2009-03-9 M9, 2009 Mar 9, 2009 March 9, 2009
2009-04-09 2009-4-9 2009-04-9 A9, 2009 Apr 9, 2009 April 9, 2009
2009-05-09 2009-5-9 2009-05-9 M9, 2009 May 9, 2009 May 9, 2009
2009-06-09 2009-6-9 2009-06-9 J9, 2009 Jun 9, 2009 June 9, 2009
2009-07-09 2009-7-9 2009-07-9 J9, 2009 Jul 9, 2009 July 9, 2009
2009-08-09 2009-8-9 2009-08-9 A9, 2009 Aug 9, 2009 August 9, 2009
2009-09-09 2009-9-9 2009-09-9 S9, 2009 Sep 9, 2009 September 9, 2009
2009-10-09 2009-10-9 2009-10-9 O9, 2009 Oct 9, 2009 October 9, 2009
2009-11-09 2009-11-9 2009-11-9 N9, 2009 Nov 9, 2009 November 9, 2009
2009-12-09 2009-12-9 2009-12-9 D9, 2009 Dec 9, 2009 December 9, 2009

Live sample shows the chart, where month formatting is used for various elements of the charts:

Live Sample:  Date-Time Formatting - Using Month Tokens

to top

Genitive month names

Genitive month names may be required for proper display of date time in some languages. You can learn how to use and configure %MMMMM and %MMMMMM tokens:

Live sample below shows date time formatting according to Russian grammar rules and standards:

Live Sample:  Date-Time Formatting - Using Genitive Month Names

to top

Days of Week

To show weekday names you can use the following tokens:

All names shown using this tokens can be redefined, learn how to do that at:

Table below shows different variants of formatting that use weekday names tokens:

Timestamp %w, %M/%d/%yyyy %ddd, %M/%d/%yyyy %dddd, %M/%d/%yyyy
2010-04-04 Su, 4/4/2010 Sun, 4/4/2010 Sunday, 4/4/2010
2010-04-05 Mo, 4/5/2010 Mon, 4/5/2010 Monday, 4/5/2010
2010-04-06 Tu, 4/6/2010 Tue, 4/6/2010 Tuesday, 4/6/2010
2010-04-07 We, 4/7/2010 Wed, 4/7/2010 Wednesday, 4/7/2010
2010-04-08 Th, 4/8/2010 Thu, 4/8/2010 Thursday, 4/8/2010
2010-04-09 Fr, 4/9/2010 Fri, 4/9/2010 Friday, 4/9/2010
2010-04-10 Sa, 4/10/2010 Sat, 4/10/2010 Saturday, 4/10/2010
2010-04-11 Su, 4/11/2010 Sun, 4/11/2010 Sunday, 4/11/2010

Table below shows different formatting that uses these tokens:

Live Sample:  Date-Time Formatting - Day of Week

to top

Number of the Week in the year

There are two tokens to show the number of the week in the year:

The way the engine calculates the number of the week depends on locale settings. Learn how it can be tuned at:

Table below shows different formatting that uses %e and %ee tokens:

Timestamp W%e-%dd-%MMM-%yyyy Week %ee of %yyyy
2009-12-31 W53-31-Dec-2009 Week 53 of 2009
2010-01-01 W1-01-Jan-2010 Week 01 of 2010
2010-01-02 W1-02-Jan-2010 Week 01 of 2010
2010-01-12 W3-12-Jan-2010 Week 03 of 2010

Live sample below shows chart that uses date time formatting with week number:

Live Sample:  Date-Time Formatting - Number of Week

to top

Day tokens

To show the day number you can use two tokens:

Table below shows different formatting that uses these tokens:

Timestamp %M/%d/%yyyy %dd.%MM.%yyyy
2009-11-03 11/3/2009 03.11.2009
2009-12-30 12/30/2009 30.12.2009
2010-01-08 1/8/2009 08.01.2009

Live sample with these tokens used in various chart elements formatting:

Live Sample:  Date-Time Formatting - Days

to top

Quarters tokens

To show quarters you can use following four tokens:

If you need to adjust values shown by %Q, %QQ and %QQQ tokens according to local standards, you can do that as described at:

Table below shows different formatting that uses these tokens:

Timestamp %q-%yyyy %Q %yyyy %QQ, %yyyy %QQQ of %yyyy
2009-02-01 1-2009 Q1 2009 Qtr 1, 2009 1st Quarter of 2009
2009-04-26 2-2009 Q2 2009 Qtr 2, 2009 2nd Quarter of 2009
2009-08-12 3-2009 Q3 2009 Qtr 3, 2009 3rd Quarter of 2009
2009-11-01 4-2009 Q4 2009 Qtr 4, 2009 4th Quarter of 2009
2010-01-05 1-2010 Q1 2010 Qtr 1, 2010 1st Quarter of 2010

Live sample with these tokens used in various chart elements formatting:

Live Sample:  Date-Time Formatting - Quarters

to top

Thirds of the month tokens

To show thirds of the month you can use these tokens:

You can redefine values shown by %C, %CC and %CCC according to local standards, as described at:

Table below shows different formatting that uses these tokens:

Timestamp Th. %c of %MMM %yyyy %MMM(%C) %yyyy %MMM(%CC) %yyyy %CCC of %MMMM %yyyy
2010-01-02 Th. 1 of Jan 2010 Jan(B) 2010 Jan(Beg) 2010 Beginning of January 2010
2010-01-11 Th. 2 of Jan 2010 Jan(M) 2010 Jan(Mid) 2010 Middle of January 2010
2010-01-23 Th. 3 of Jan 2010 Jan(E) 2010 Jan(End) 2010 End of January 2010
2010-02-01 Th. 1 of Feb 2010 Feb(B) 2010 Feb(Beg) 2010 Beginning of February 2010

Live sample with these tokens used in various chart elements formatting:

Live Sample:  Date-Time Formatting - Thirds of Months

to top

Semesters tokens

To show semesters you can use these tokens:

You can change values shown by %R, %RR and %RRR tokens to adjust them to local standards, to learn how to do that see:

Table below shows different formatting that uses these tokens:

Timestamp %r, %yyyy %R, %yyyy %RR, %yyyy %RRR of %yyyy
2009-03-10 1, 2009 H1, 2009 Half 1, 2009 1st Half of 2009
2009-11-20 2, 2009 H2, 2009 Half 2, 2009 2nd Half of 2009
2010-04-01 1, 2010 H1, 2010 Half 1, 2010 1st Half of 2010
2010-07-30 2, 2010 H2, 2010 Half 2, 2010 2nd Half of 2010

Live sample with these tokens used in various chart elements formatting:

Live Sample:  Date-Time Formatting - Semesters

to top

Timestamps tokens (debug)

The following tokens are rarely used to display data, but probably useful in debugging (and very useful for data input):

Live sample with these tokens used in various chart elements formatting:

Live Sample:  Date-Time Formatting - Timestamps

to top

Adaptive Date-Time Formatting

When the use of grouping changes the grouping interval, the data details change as well; for example, when a chart is shown in daily intervals, the date and time are shown as "21 May, 2009" or "16 Apr, 2009"; but when the data groups into months, the date and time are shown as "1 May, 2009" or "1 Apr 2009", because all the month's data is represented by the one day of the month.

But user may be confused with this label and prefer to see a label like "May, 2009".

To solve this issue and prevent the confusion, use adaptive date-time formatting, which allows to set how the elements change their format depending on the grouping level.

This mechanism is described in detail in:

to top

Localization and Date-Time Formatting Utility

To make the process of localization easier, we have created a special utility that allows obtaining all the settings available in AnyChart Stock for more than 130 languages and dialects with ease.

But, what is more important in connection with the topic of this article, this utility allows to obtain preset date time formatting patterns and create and test your own.

This application allows choosing the preset date-time formats related to the given language or, as already said, create you own; these settings are instantly shown on the sample charts in the Preview panels.

You can adjust these settings any way you want. And when you are done with them, you can copy them from the XML or JSON Settings tabs.

This utility can be found at the AnyChart web site:

to top