DateFormatter
Type class
Handles date and time formatting.
More info: Formatting Date & Time Tutorial on date/time formatting
Sources
DateFormatter can be used (imported) via one of the following packages.
/** * Import from: "core.ts" * Use like: am4core.DateFormatter */import * as am4core from "@amcharts/amcharts4/core";/** * Include via: <script src="core.js"></script> * Access items like: am4core.DateFormatter */Inheritance
DateFormatter extends BaseObject.
DateFormatter is not extended by any other symbol.
Properties
capitalizeType
booleanDefaulttrueShould the first letter of the formatted date be capitalized?
dateFormatType
string|DateTimeFormatOptionsDefault"yyyy-MM-dd"Date format to use.
If format is not supplied in-line in the string, this setting will be used.
firstDayOfWeekType
numberFirst day of the week:
0 - Sunday
1 - Monday
2 - Tuesday Etc.
inputDateFormatType
stringDefault"yyyy-MM-dd"Date format to use when parsing dates.
intlLocalesType
stringLocales if you are using date formats in
Intl.DateTimeFormatOptionssyntax.languageType
$type.Optional<Language>A reference to
Languageobject.monthsType
Array<MonthNames>Default[ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]A list of month names.
monthsShortType
Array<ShortMonthNames>Default[ "Jan", "Feb", "Mar", "Apr", "May(short)", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]A list of short month names.
spriteType
$type.Optional<Sprite>Holds reference to parent
Spriteobject.timezoneType
$type.Optional<string>Since 4.10.1If set, will format date/time in specific time zone.
The value should be named time zone, e.g.:
"America/Vancouver","Australia/Sydney","UTC".timezoneOffsetType
$type.Optional<number>If set, will apply specific offset in minutes before formatting the date text.
The value is a number of minutes from target time zone to UTC.
E.g.
300will recalculate Dates in "GMT-5" time zone.utcType
booleanShould formatter use UTC functions?
If UTC is used, all date/time values will be independent on client's time zone.
weekdaysType
Array<Weekdays>Default[ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]A list of weekday names.
weekdaysShortType
Array<ShortWeekdays>Default[ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ]A list of short weekday names.
4 inherited items
clonedFromType
$type.Optional<this>Inherited fromBaseObjectReference to the original object this object was cloned from. We need to keep this so we can disassociate it from source object when this object is disposed.
configType
objectInherited fromBaseObjectUse this property to set JSON-based config. When set, triggers processing routine, which will go through all properties, and try to apply values, create instances, etc.
Use this with caution, as it is a time-consuming process. It's used for initialchart setup only, not routine operations.
idType
$type.Optional<string>Inherited fromBaseObjectSets the user-defined id of the element.
uidType
stringInherited fromBaseObjectReturns object's internal unique ID.
Methods
constructor()Returns
DateFormatterConstructor
format(source:any,
format?:string|DateTimeFormatOptions,
applyTimezone?:boolean)Returns
stringFormats the date value according to specified format.
More info: Formatting Date & Time Tutorial on date/time formatting
parse(source:any,
format?:string)Returns
DateParses any input value into Date object.
More info: Formatting Date & Time: parsing dates Tutorial on date/time parsing
5 inherited items
clone(cloneId?:string)Returns
thisInherited fromBaseObjectMakes a copy of this object and returns the clone. Try to avoid cloning complex objects like chart, create new instances if you need them.
copyFrom(object:this)Returns
voidInherited fromBaseObjectCopies all properties and related data from different element.
dispose()Returns
voidInherited fromBaseObjectDestroys this object and all related data.
getCurrentThemes()Returns
ITheme[]Inherited fromBaseObjectReturns a list of themes that should be applied to this element. It could either be a list of themes set explicitly on this element, or system-wide.
isDisposed()Returns
booleanInherited fromBaseObjectReturns if this object has been already been disposed.
Events
DateFormatter does not have any events.