The Date type - represents milliseconds since Unix epoch, or NaN for invalid dates
Constructors
Returns a date representing the current time
Create a Date from epoch milliseconds
Create a Date by parsing a string
Sourceval makeWithYM : year:float -> month:float -> t Create a Date from year and month (local time). Note: Years 0-99 are treated as 1900-1999
Sourceval makeWithYMD : year:float -> month:float -> date:float -> t Create a Date from year, month, date (local time)
Sourceval makeWithYMDH : year:float -> month:float -> date:float -> hours:float -> t Create a Date from year, month, date, hours (local time)
Sourceval makeWithYMDHM :
year:float ->
month:float ->
date:float ->
hours:float ->
minutes:float ->
t Create a Date from year, month, date, hours, minutes (local time)
Sourceval makeWithYMDHMS :
year:float ->
month:float ->
date:float ->
hours:float ->
minutes:float ->
seconds:float ->
t Create a Date from all components (local time)
Date.UTC constructors
Sourceval utc :
year:float ->
month:float ->
?day:float ->
?hours:float ->
?minutes:float ->
?seconds:float ->
?ms:float ->
unit ->
float Date.UTC(year, month, date[, hours[, minutes[, seconds[, ms]]]]) Returns epoch milliseconds for the given UTC date components. Note: Years 0-99 are treated as 1900-1999
Sourceval utcWithYM : year:float -> month:float -> float Date.UTC with year and month only
Sourceval utcWithYMD : year:float -> month:float -> date:float -> float Date.UTC with year, month, date
Sourceval utcWithYMDH :
year:float ->
month:float ->
date:float ->
hours:float ->
float Date.UTC with year, month, date, hours
Sourceval utcWithYMDHM :
year:float ->
month:float ->
date:float ->
hours:float ->
minutes:float ->
float Date.UTC with year, month, date, hours, minutes
Sourceval utcWithYMDHMS :
year:float ->
month:float ->
date:float ->
hours:float ->
minutes:float ->
seconds:float ->
float Date.UTC with all components
Date.now and Date.parse
Date.now() - returns current time as epoch milliseconds
Sourceval parse : string -> float Date.parse(string) - parses a date string, returns NaN on failure. Supports ISO 8601 and legacy formats.
Sourceval parseAsFloat : string -> float UTC Getters
Returns the primitive value (epoch ms), equivalent to getTime
Returns the epoch milliseconds
Returns the day of the month (1-31) in UTC
Returns the day of the week (0=Sunday, 6=Saturday) in UTC
Sourceval getUTCFullYear : t -> float Returns the hours (0-23) in UTC
Sourceval getUTCMilliseconds : t -> float Returns the milliseconds (0-999) in UTC
Sourceval getUTCMinutes : t -> float Returns the minutes (0-59) in UTC
Returns the month (0-11) in UTC
Sourceval getUTCSeconds : t -> float Returns the seconds (0-59) in UTC
Local Time Getters
Returns the day of the month (1-31) in local time
Returns the day of the week (0=Sunday, 6=Saturday) in local time
Returns the year in local time
Returns the hours (0-23) in local time
Sourceval getMilliseconds : t -> float Returns the milliseconds (0-999) in local time
Returns the minutes (0-59) in local time
Returns the month (0-11) in local time
Returns the seconds (0-59) in local time
Sourceval getTimezoneOffset : t -> float Returns the timezone offset in minutes (positive = west of UTC)
UTC Setters
All setters return the new timestamp (milliseconds).
Sourceval setUTCDate : float -> t -> float Sourceval setUTCFullYear : float -> t -> float Sourceval setUTCFullYearM : year:float -> month:float -> t -> float Sourceval setUTCFullYearMD : year:float -> month:float -> date:float -> t -> float Sourceval setUTCHours : float -> t -> float Sourceval setUTCHoursM : hours:float -> minutes:float -> t -> float Sourceval setUTCHoursMS : hours:float -> minutes:float -> seconds:float -> t -> float Sourceval setUTCHoursMSMs :
hours:float ->
minutes:float ->
seconds:float ->
milliseconds:float ->
t ->
float Sourceval setUTCMilliseconds : float -> t -> float Sourceval setUTCMinutes : float -> t -> float Sourceval setUTCMinutesS : minutes:float -> seconds:float -> t -> float Sourceval setUTCMinutesSMs :
minutes:float ->
seconds:float ->
milliseconds:float ->
t ->
float Sourceval setUTCMonth : float -> t -> float Sourceval setUTCMonthD : month:float -> date:float -> t -> float Sourceval setUTCSeconds : float -> t -> float Sourceval setUTCSecondsMs : seconds:float -> milliseconds:float -> t -> float Sourceval setUTCTime : float -> t -> float Local Time Setters
All setters return the new timestamp (milliseconds).
Sourceval setDate : float -> t -> float Sourceval setFullYear : float -> t -> float Sourceval setFullYearM : year:float -> month:float -> t -> float Sourceval setFullYearMD : year:float -> month:float -> date:float -> t -> float Sourceval setHours : float -> t -> float Sourceval setHoursM : hours:float -> minutes:float -> t -> float Sourceval setHoursMS : hours:float -> minutes:float -> seconds:float -> t -> float Sourceval setHoursMSMs :
hours:float ->
minutes:float ->
seconds:float ->
milliseconds:float ->
t ->
float Sourceval setMilliseconds : float -> t -> float Sourceval setMinutes : float -> t -> float Sourceval setMinutesS : minutes:float -> seconds:float -> t -> float Sourceval setMinutesSMs :
minutes:float ->
seconds:float ->
milliseconds:float ->
t ->
float Sourceval setMonth : float -> t -> float Sourceval setMonthD : month:float -> date:float -> t -> float Sourceval setSeconds : float -> t -> float Sourceval setSecondsMs : seconds:float -> milliseconds:float -> t -> float Sourceval setTime : float -> t -> float String Conversion
Sourceval toDateString : t -> string Returns a human-readable date string (local time)
Sourceval toISOString : t -> string Returns an ISO 8601 formatted string: "YYYY-MM-DDTHH:mm:ss.sssZ" Raises Invalid_argument for invalid dates
Sourceval toJSON : t -> string option Returns ISO string wrapped in option, None for invalid dates
Sourceval toJSONUnsafe : t -> string Same as toISOString - throws for invalid dates
Sourceval toLocaleDateString : t -> string Returns locale-formatted date string (simplified implementation)
Sourceval toLocaleString : t -> string Returns locale-formatted string (simplified implementation)
Sourceval toLocaleTimeString : t -> string Returns locale-formatted time string (simplified implementation)
Returns full string representation in local time
Sourceval toTimeString : t -> string Returns time string in local time
Sourceval toUTCString : t -> string Returns string in UTC: "Tue, 02 Dec 2025 09:30:00 GMT"