@fuel-ts/utils v0.97.0 • Docs
This class is used to represent a date and time in the Tai64 format.
import { DateTime } from 'fuels';
// Constants
const tai64 = '4611686020108779340';
const unixMilliseconds = 1681391398000;
const seconds = 1681391398;
// Instantiation
let date: DateTime = DateTime.now();
date = DateTime.fromTai64(tai64);
date = DateTime.fromUnixMilliseconds(unixMilliseconds);
date = DateTime.fromUnixSeconds(seconds);
// Utility functions
tai64.toTai64() // '4611686020108779340'
milliseconds.toUnixMilliseconds() // 1681391398000
seconds.toUnixSeconds() // 1681391398
// All date methods are available
const now: Date = DateTime.now();
now.toISOString(); // '2023-04-13T13:09:58.000Z'
now.getTime(); // 1681391398000
Date
Date
static
TAI64_NULL:string
=''
packages/utils/src/utils/date-time.ts:99
[toPrimitive](
hint
):string
Converts a Date object to a string.
• hint: "default"
string
Date.[toPrimitive]
Date.[toPrimitive]
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:116
[toPrimitive](
hint
):string
Converts a Date object to a string.
• hint: "string"
string
Date.[toPrimitive]
Date.[toPrimitive]
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:120
[toPrimitive](
hint
):number
Converts a Date object to a number.
• hint: "number"
number
Date.[toPrimitive]
Date.[toPrimitive]
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:124
[toPrimitive](
hint
):string
|number
Converts a Date object to a string or number.
• hint: string
The strings "number", "string", or "default" to specify what primitive to return.
string
| number
A number if 'hint' was "number", a string if 'hint' was "string" or "default".
If 'hint' was given something other than "number", "string", or "default".
Date.[toPrimitive]
Date.[toPrimitive]
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:133
getDate():
number
Gets the day-of-the-month, using local time.
number
Date.getDate
Date.getDate
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:798
getDay():
number
Gets the day of the week, using local time.
number
Date.getDay
Date.getDay
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:802
getFullYear():
number
Gets the year, using local time.
number
Date.getFullYear
Date.getFullYear
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:790
getHours():
number
Gets the hours in a date, using local time.
number
Date.getHours
Date.getHours
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:806
getMilliseconds():
number
Gets the milliseconds of a Date, using local time.
number
Date.getMilliseconds
Date.getMilliseconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:818
getMinutes():
number
Gets the minutes of a Date object, using local time.
number
Date.getMinutes
Date.getMinutes
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:810
getMonth():
number
Gets the month, using local time.
number
Date.getMonth
Date.getMonth
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:794
getSeconds():
number
Gets the seconds of a Date object, using local time.
number
Date.getSeconds
Date.getSeconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:814
getTime():
number
Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
number
Date.getTime
Date.getTime
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:788
getTimezoneOffset():
number
Gets the difference in minutes between Universal Coordinated Time (UTC) and the time on the local computer.
number
Date.getTimezoneOffset
Date.getTimezoneOffset
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:822
getUTCDate():
number
Gets the day-of-the-month, using Universal Coordinated Time (UTC).
number
Date.getUTCDate
Date.getUTCDate
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:800
getUTCDay():
number
Gets the day of the week using Universal Coordinated Time (UTC).
number
Date.getUTCDay
Date.getUTCDay
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:804
getUTCFullYear():
number
Gets the year using Universal Coordinated Time (UTC).
number
Date.getUTCFullYear
Date.getUTCFullYear
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:792
getUTCHours():
number
Gets the hours value in a Date object using Universal Coordinated Time (UTC).
number
Date.getUTCHours
Date.getUTCHours
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:808
getUTCMilliseconds():
number
Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).
number
Date.getUTCMilliseconds
Date.getUTCMilliseconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:820
getUTCMinutes():
number
Gets the minutes of a Date object using Universal Coordinated Time (UTC).
number
Date.getUTCMinutes
Date.getUTCMinutes
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:812
getUTCMonth():
number
Gets the month of a Date object using Universal Coordinated Time (UTC).
number
Date.getUTCMonth
Date.getUTCMonth
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:796
getUTCSeconds():
number
Gets the seconds of a Date object using Universal Coordinated Time (UTC).
number
Date.getUTCSeconds
Date.getUTCSeconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:816
setDate(
date
):number
Sets the numeric day-of-the-month value of the Date object using local time.
• date: number
A numeric value equal to the day of the month.
number
Date.setDate
Date.setDate
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:885
setFullYear(
year
,month
?,date
?):number
Sets the year of the Date object using local time.
• year: number
A numeric value for the year.
• month?: number
A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
• date?: number
A numeric value equal for the day of the month.
number
Date.setFullYear
Date.setFullYear
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:909
setHours(
hours
,min
?,sec
?,ms
?):number
Sets the hour value in the Date object using local time.
• hours: number
A numeric value equal to the hours value.
• min?: number
A numeric value equal to the minutes value.
• sec?: number
A numeric value equal to the seconds value.
• ms?: number
A numeric value equal to the milliseconds value.
number
Date.setHours
Date.setHours
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:872
setMilliseconds(
ms
):number
Sets the milliseconds value in the Date object using local time.
• ms: number
A numeric value equal to the millisecond value.
number
Date.setMilliseconds
Date.setMilliseconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:832
setMinutes(
min
,sec
?,ms
?):number
Sets the minutes value in the Date object using local time.
• min: number
A numeric value equal to the minutes value.
• sec?: number
A numeric value equal to the seconds value.
• ms?: number
A numeric value equal to the milliseconds value.
number
Date.setMinutes
Date.setMinutes
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:857
setMonth(
month
,date
?):number
Sets the month value in the Date object using local time.
• month: number
A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
• date?: number
A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.
number
Date.setMonth
Date.setMonth
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:896
setSeconds(
sec
,ms
?):number
Sets the seconds value in the Date object using local time.
• sec: number
A numeric value equal to the seconds value.
• ms?: number
A numeric value equal to the milliseconds value.
number
Date.setSeconds
Date.setSeconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:844
setTime(
time
):number
Sets the date and time value in the Date object.
• time: number
A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
number
Date.setTime
Date.setTime
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:827
setUTCDate(
date
):number
Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
• date: number
A numeric value equal to the day of the month.
number
Date.setUTCDate
Date.setUTCDate
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:890
setUTCFullYear(
year
,month
?,date
?):number
Sets the year value in the Date object using Universal Coordinated Time (UTC).
• year: number
A numeric value equal to the year.
• month?: number
A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
• date?: number
A numeric value equal to the day of the month.
number
Date.setUTCFullYear
Date.setUTCFullYear
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:916
setUTCHours(
hours
,min
?,sec
?,ms
?):number
Sets the hours value in the Date object using Universal Coordinated Time (UTC).
• hours: number
A numeric value equal to the hours value.
• min?: number
A numeric value equal to the minutes value.
• sec?: number
A numeric value equal to the seconds value.
• ms?: number
A numeric value equal to the milliseconds value.
number
Date.setUTCHours
Date.setUTCHours
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:880
setUTCMilliseconds(
ms
):number
Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
• ms: number
A numeric value equal to the millisecond value.
number
Date.setUTCMilliseconds
Date.setUTCMilliseconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:837
setUTCMinutes(
min
,sec
?,ms
?):number
Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
• min: number
A numeric value equal to the minutes value.
• sec?: number
A numeric value equal to the seconds value.
• ms?: number
A numeric value equal to the milliseconds value.
number
Date.setUTCMinutes
Date.setUTCMinutes
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:864
setUTCMonth(
month
,date
?):number
Sets the month value in the Date object using Universal Coordinated Time (UTC).
• month: number
A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
• date?: number
A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.
number
Date.setUTCMonth
Date.setUTCMonth
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:902
setUTCSeconds(
sec
,ms
?):number
Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
• sec: number
A numeric value equal to the seconds value.
• ms?: number
A numeric value equal to the milliseconds value.
number
Date.setUTCSeconds
Date.setUTCSeconds
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:850
toDateString():
string
Returns a date as a string value.
string
Date.toDateString
Date.toDateString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:776
toISOString():
string
Returns a date as a string value in ISO format.
string
Date.toISOString
Date.toISOString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:920
toJSON(
key
?):string
Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization.
• key?: any
string
Date.toJSON
Date.toJSON
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:922
toLocaleDateString():
string
Returns a date as a string value appropriate to the host environment's current locale.
string
Date.toLocaleDateString
Date.toLocaleDateString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:782
toLocaleDateString(
locales
?,options
?):string
Converts a date to a string by using the current or specified locale.
• locales?: string
| string
[]
A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
• options?: DateTimeFormatOptions
An object that contains one or more properties that specify comparison options.
string
Date.toLocaleDateString
Date.toLocaleDateString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:4577
toLocaleDateString(
locales
?,options
?):string
Converts a date to a string by using the current or specified locale.
• locales?: LocalesArgument
A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
• options?: DateTimeFormatOptions
An object that contains one or more properties that specify comparison options.
string
Date.toLocaleDateString
Date.toLocaleDateString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2020.date.d.ts:34
toLocaleString():
string
Returns a value as a string value appropriate to the host environment's current locale.
string
Date.toLocaleString
Date.toLocaleString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:780
toLocaleString(
locales
?,options
?):string
Converts a date and time to a string by using the current or specified locale.
• locales?: string
| string
[]
A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
• options?: DateTimeFormatOptions
An object that contains one or more properties that specify comparison options.
string
Date.toLocaleString
Date.toLocaleString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:4571
toLocaleString(
locales
?,options
?):string
Converts a date and time to a string by using the current or specified locale.
• locales?: LocalesArgument
A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
• options?: DateTimeFormatOptions
An object that contains one or more properties that specify comparison options.
string
Date.toLocaleString
Date.toLocaleString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2020.date.d.ts:27
toLocaleTimeString():
string
Returns a time as a string value appropriate to the host environment's current locale.
string
Date.toLocaleTimeString
Date.toLocaleTimeString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:784
toLocaleTimeString(
locales
?,options
?):string
Converts a time to a string by using the current or specified locale.
• locales?: string
| string
[]
A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
• options?: DateTimeFormatOptions
An object that contains one or more properties that specify comparison options.
string
Date.toLocaleTimeString
Date.toLocaleTimeString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:4584
toLocaleTimeString(
locales
?,options
?):string
Converts a time to a string by using the current or specified locale.
• locales?: LocalesArgument
A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.
• options?: DateTimeFormatOptions
An object that contains one or more properties that specify comparison options.
string
Date.toLocaleTimeString
Date.toLocaleTimeString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2020.date.d.ts:41
toString():
string
Returns a string representation of a date. The format of the string depends on the locale.
string
Date.toString
Date.toString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:774
toTai64():
string
Returns the Tai64 timestamp.
string
the Tai64 timestamp
packages/utils/src/utils/date-time.ts:139
toTimeString():
string
Returns a time as a string value.
string
Date.toTimeString
Date.toTimeString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:778
toUTCString():
string
Returns a date converted to a string using Universal Coordinated Time (UTC).
string
Date.toUTCString
Date.toUTCString
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:918
toUnixMilliseconds():
number
number
the unix milliseconds timestamp
packages/utils/src/utils/date-time.ts:146
toUnixSeconds():
number
number
the unix seconds timestamp
packages/utils/src/utils/date-time.ts:153
valueOf():
number
Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.
number
Date.valueOf
Date.valueOf
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:786
static
UTC(year
,monthIndex
,date
?,hours
?,minutes
?,seconds
?,ms
?):number
Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
• year: number
The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
• monthIndex: number
The month as a number between 0 and 11 (January to December).
• date?: number
The date as a number between 1 and 31.
• hours?: number
Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
• minutes?: number
Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
• seconds?: number
Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
• ms?: number
A number from 0 to 999 that specifies the milliseconds.
number
Date.UTC
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:956
static
UTC(year
,monthIndex
?,date
?,hours
?,minutes
?,seconds
?,ms
?):number
Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
• year: number
The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
• monthIndex?: number
The month as a number between 0 and 11 (January to December).
• date?: number
The date as a number between 1 and 31.
• hours?: number
Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.
• minutes?: number
Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.
• seconds?: number
Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.
• ms?: number
A number from 0 to 999 that specifies the milliseconds.
number
Date.UTC
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es2017.date.d.ts:30
static
fromTai64(tai64
):DateTime
Generates a new DateTime instance from a Tai64 timestamp.
• tai64: string
Tai64 timestamp
a new DateTime instance
packages/utils/src/utils/date-time.ts:107
static
fromUnixMilliseconds(unixMilliseconds
):DateTime
• unixMilliseconds: number
unix milliseconds timestamp
a new DateTime instance
packages/utils/src/utils/date-time.ts:115
static
fromUnixSeconds(unixSeconds
):DateTime
• unixSeconds: number
unix seconds timestamp
a new DateTime instance
packages/utils/src/utils/date-time.ts:123
static
now():number
Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).
number
Date.now
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:958
static
parse(s
):number
Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.
• s: string
A date string
number
Date.parse
node_modules/.pnpm/typescript@5.6.3/node_modules/typescript/lib/lib.es5.d.ts:945