Date/Time Localization and Input

Overview

You can use Date/Time values as input data for chart, moreover - you can localize input data format so you don't have to reformat it before setting data to XML.

to top

DateTime Input Localization

Localization of Input and output data is done in <locale> sub node of <settings> node:

XML Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <anychart>
03   <settings>
04     <locale />
05   </settings>
06 </anychart>

In this node you can define input format of date/time values using datetime formattin keywords, for example if you set:

XML Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <anychart>
03   <settings>
04     <locale>
05       <date_time_format>
06         <format><![CDATA[%HH:%mm:%ss %dd/%MM/%yyyy]]></format>
07       </date_time_format>
08     </locale>
09   </settings>
10 </anychart>

You can use this format as input for x values in Scatter charts with datetime axis:

XML Syntax
Plain code
01 <point x="13:47:00 22/05/1991" y="20" name="Today" />

This chart demonstrates this local settings:

Live Sample:  Date Time Input Localization Settings

to top

UNIX DateTime Input

Also, you can use UNIX datetime as input using %U keyword:

XML Syntax
Plain code
01 <?xml version="1.0" encoding="UTF-8"?>
02 <anychart>
03   <settings>
04     <locale>
05       <date_time_format>
06         <format><![CDATA[%U]]></format>
07       </date_time_format>
08     </locale>
09   </settings>
10 </anychart>

This sample demonstrates UNIX Date time as input and it is formatted to be shown in tooltips as usual:

Live Sample:  Date Time Input Localization Settings UNIX datetime

DateTime Output Localization

Also, you can localize the following values to be used in datetime formatting:

To do that you have to set it in <locale> node:

XML Syntax
Plain code
01 <locale>
02   <number_format decimal_separator="." thousands_separator="," />
03   <date_time_format>
04     <months>
05       <names><![CDATA[January,February,March,April,May,June,July,August,September,October,November,December]]></names>
06       <short_names><![CDATA[Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec]]></short_names>
07     </months>
08     <time am_string="AM" short_am_string="A" pm_string="PM" short_pm_string="P" />
09     <week_days start_from="Sunday">
10       <names><![CDATA[Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday]]></names>
11       <short_names><![CDATA[Sun,Mon,Tue,Wed,Thu,Fri,Sat]]></short_names>
12     </week_days>
13   </date_time_format>
14 </locale>

The sample below shows datetime localized so it display months and days names in French:

Live Sample:  Date Time Input Localization Settings French names

to top