Skip to content

Time

Type module

Sources

Items from Time can be imported/included and used via following ways.

/**
* Import via main package
* Access items like: am5.time.myVariable
*/
import * as am5 from "@amcharts/amcharts5";
/**
* Import via: Time.ts
* Access items like: $time.myVariable
*/
import * as $time from "@amcharts/amcharts5/Time";

Variables

Time does not have any variables.

Functions

add(array: Array,
element: A,
index?: undefined | number
)

Returns void

Adds count units of time to date. Changes date itself and returns it.

addInTimezone(date: Date,
unit: TimeUnit,
count: number,
timezone: Timezone
)

Returns Date

add() in a named timezone: days, weeks, months and years keep the time of day on the zone's clock, smaller units add elapsed time.

checkChange(timeOne: number,
timeTwo: number,
unit: TimeUnit,
utc?: undefined | false | true,
timezone?: Timezone
)

Returns boolean

Returns true if two timestamps fall in different periods of unit, such as on different days for "day".

copy(array: ArrayLike)

Returns Array

Returns a shallow copy of the object.

Returns a copy of the Date object.

Returns a copy of the Date object.

getDateIntervalDuration(interval: ITimeInterval,
date: Date,
firstDateOfWeek?: undefined | number,
utc?: undefined | false | true,
timezone?: Timezone
)

Returns number

Returns the length of interval in milliseconds, for the period that date falls in. Days, weeks, months and years get their real length there, such as 29 days for February 2024.

getDuration(unit: TimeUnit,
count?: undefined | number
)

Returns number

Returns the length of count units of time, in milliseconds. A month counts as an average month (about 30.44 days), a year as 365 days.

getTime()

Returns number

Returns current timestamp.

now()

Returns Date

Returns current Date object.

round(value: number,
precision?: undefined | number,
floor?: undefined | false | true
)

Returns number

Rounds a date down to the start of its period of count units, such as to midnight for "day". May change date itself.

sleep(ms: number)

Returns Promise

Returns a promise that resolves after ms milliseconds.