stime › Globals › "Time" › Time
A representation of time
-
↳ Time
- format
- getDay
- getDayOfWeek
- getHours
- getMinutes
- getMonth
- getSeconds
- getYear
- toLocaleString
- toTimestamp
+ new Time(root
: Date): Time
Defined in Time.ts:10
Create a new Time instance
Parameters:
Name | Type | Description |
---|---|---|
root |
Date | Native date to base the time on |
Returns: Time
• root: Date
Defined in Time.ts:10
var
{Date} root Native date
▸ format(format
: string): string
Inherited from Formattable.format
Defined in Formattable.ts:32
Format the date into a string
example
time.format(':leadingDay:/:leadingMonth:/:fullYear:'); // 01/01/2020
Parameters:
Name | Type | Description |
---|---|---|
format |
string | Format to turn the date into. |
Returns: string
Formatted date
▸ getDay(): number
Overrides Formattable.getDay
Defined in Time.ts:35
Get the day of the month
Returns: number
Day of the month
▸ getDayOfWeek(): number
Overrides Formattable.getDayOfWeek
Defined in Time.ts:83
Get day of week
Returns: number
0-6 / Sunday-Saturday
▸ getHours(): number
Overrides Formattable.getHours
Defined in Time.ts:75
Get hours
Returns: number
Hours
▸ getMinutes(): number
Overrides Formattable.getMinutes
Defined in Time.ts:67
Get minutes
Returns: number
Minutes
▸ getMonth(): number
Overrides Formattable.getMonth
Defined in Time.ts:43
Get the month number
Returns: number
Month number from 1 to 12
▸ getSeconds(): number
Overrides Formattable.getSeconds
Defined in Time.ts:59
Get the seconds
Returns: number
Seconds
▸ getYear(): number
Overrides Formattable.getYear
Defined in Time.ts:51
Get the year
Returns: number
4-digit representation of the year
▸ toLocaleString(locales
: string, options
: any): string
Overrides Formattable.toLocaleString
Defined in Time.ts:92
Get the time as a locale string
Parameters:
Name | Type | Description |
---|---|---|
locales |
string | Locales to get the string for |
options |
any |
Returns: string
▸ toTimestamp(): number
Defined in Time.ts:27
Get unix timestamp representation
example
const unixTimestamp = time.toTimestamp();
Returns: number
Unix timetamp