static/jsvm/classes/DateTime.html
DateTime defines a single DateTime type instance. The returned date is always represented in UTC.
Example:
const dt0 = new DateTime() // now// full datetime stringconst dt1 = new DateTime('2023-07-01 00:00:00.000Z')// datetime string with default "parse in" timezone location//// similar to new DateTime('2023-07-01 00:00:00 +01:00') or new DateTime('2023-07-01 00:00:00 +02:00')// but accounts for the daylight saving time (DST)const dt2 = new DateTime('2023-07-01 00:00:00', 'Europe/Amsterdam')Copy
addaddDateafterbeforecompareequalisZeromarshalJSONscanstringsubtimeunixunmarshalJSONvalue
Optional date: stringOptional defaultParseInLocation: stringAdd returns a new DateTime based on the current DateTime + the specified duration.
AddDate returns a new DateTime based on the current one + duration.
It follows the same rules as [time.AddDate].
After reports whether the current DateTime instance is after u.
Before reports whether the current DateTime instance is before u.
Compare compares the current DateTime instance with u. If the current instance is before u, it returns -1. If the current instance is after u, it returns +1. If they're the same, it returns 0.
Equal reports whether the current DateTime and u represent the same time instant. Two DateTime can be equal even if they are in different locations. For example, 6:00 +0200 and 4:00 UTC are Equal.
IsZero checks whether the current DateTime instance has zero time value.
MarshalJSON implements the [json.Marshaler] interface.
Scan implements [sql.Scanner] interface to scan the provided value into the current DateTime instance.
String serializes the current DateTime instance into a formatted UTC date string.
The zero value is serialized to an empty string.
Sub returns a [time.Duration] by subtracting the specified DateTime from the current one.
If the result exceeds the maximum (or minimum) value that can be stored in a [time.Duration], the maximum (or minimum) duration will be returned.
Time returns the internal [time.Time] instance.
Unix returns the current DateTime as a Unix time, aka. the number of seconds elapsed since January 1, 1970 UTC.
UnmarshalJSON implements the [json.Unmarshaler] interface.
Value implements the [driver.Valuer] interface.
OSLightDark
Generated using TypeDoc