DateFormatter

Type class

Handles date and time formatting.

@see This link Tutorial on date/time formatting
@todo Better type casting of passed in date?
@todo Quarter support?
@todo When parsing named months make the search case-insensitive
@todo Escape a.m./p.m. properly when used in RegEx

Sources

DateFormatter can be used (imported) via one of the following packages.

// DateFormatter is available in all of the following modules.
// You only need to import one of them.

/**
 * --------------------------------------------------------
 * Import from: "core.ts"
 * Use like: am4core.DateFormatter
 * --------------------------------------------------------
 */
import * as am4core from "@amcharts/amcharts4/core";

// DateFormatter is available in all of the following modules.
// You only need to import one of them.

/**
 * --------------------------------------------------------
 * 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

capitalize
#

Type boolean

Default true

Should the first letter of the formatted date be capitalized?

@default true

clonedFrom
#

Type $type.Optional < this >

Inherited from BaseObject

Reference 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.

config
#

Type object

Inherited from BaseObject

Use 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.

dateFormat
#

Type string | DateTimeFormatOptions

Date format to use.

If format is not supplied in-line in the string, this setting will be used.

@default "yyyy-MM-dd"

firstDayOfWeek
#

Type number

Dirst day of the week:

  • 0 - Sunday
  • 1 - Monday
  • 2 - Tuesday Etc.

id
#

Type $type.Optional < string >

Inherited from BaseObject

Sets the user-defined id of the element.

inputDateFormat
#

Type string

Date format to use when parsing dates.

@default "yyyy-MM-dd"

intlLocales
#

Type string

Locales if you are using date formats in Intl.DateTimeFormatOptions syntax.

language
#

Type $type.Optional < Language >

A reference to Language object.

sprite
#

Type $type.Optional < Sprite >

Holds reference to parent Sprite object.

timezoneOffset
#

Type $type.Optional < number >

If set, will format date/time in specific time zone.

The value is a number of minutes from target time zone to UTC.

E.g. 300 will recalculate Dates in "GMT-5" time zone.

uid
#

Type string

Inherited from BaseObject

Returns object's internal unique ID.

utc
#

Type boolean

Should formatter use UTC functions?

If UTC is used, all date/time values will be independent on client's time zone.

There are 4 inherited items currently hidden from this list.

Methods

constructor()

#

Returns DateFormatter

Constructor

clone(

cloneId?: string

)

#

Returns this

Inherited from BaseObject

Makes 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 void

Inherited from BaseObject

Copies all properties and related data from different element.

dispose()

#

Returns void

Inherited from BaseObject

Destroys this object and all related data.

format(

source: any,
format?: string | DateTimeFormatOptions

)

#

Returns string

Formats the date value according to specified format.

@see This link Tutorial on date/time formatting

getCurrentThemes()

#

Returns ITheme[]

Inherited from BaseObject

Returns 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 boolean

Inherited from BaseObject

Returns if this object has been already been disposed.

parse(

source: any,
format?: string

)

#

Returns Date

Parses any input value into Date object.

@see This link Tutorial on date/time parsing

There are 5 inherited items currently hidden from this list.

Events

DateFormatter does not have any events.

Adapters

DateFormatter does not have any adapters.