This is the latest docs version
Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • Twitter
  • GitHub
  • Forum
Js Module
Overview
Js
submodules
  • Array
  • Array2
  • BigInt
  • Blob
  • Console
  • Date
    • t
      t
    • v
      valueOf
    • v
      make
    • v
      fromFloat
    • v
      fromString
    • v
      makeWithYM
    • v
      makeWithYMD
    • v
      makeWithYMDH
    • v
      makeWithYMDHM
    • v
      makeWithYMDHMS
    • v
      utcWithYM
    • v
      utcWithYMD
    • v
      utcWithYMDH
    • v
      utcWithYMDHM
    • v
      utcWithYMDHMS
    • v
      now
    • v
      parse
      D
    • v
      parseAsFloat
    • v
      getDate
    • v
      getDay
    • v
      getFullYear
    • v
      getHours
    • v
      getMilliseconds
    • v
      getMinutes
    • v
      getMonth
    • v
      getSeconds
    • v
      getTime
    • v
      getTimezoneOffset
    • v
      getUTCDate
    • v
      getUTCDay
    • v
      getUTCFullYear
    • v
      getUTCHours
    • v
      getUTCMilliseconds
    • v
      getUTCMinutes
    • v
      getUTCMonth
    • v
      getUTCSeconds
    • v
      getYear
      D
    • v
      setDate
    • v
      setFullYear
    • v
      setFullYearM
    • v
      setFullYearMD
    • v
      setHours
    • v
      setHoursM
    • v
      setHoursMS
    • v
      setHoursMSMs
    • v
      setMilliseconds
    • v
      setMinutes
    • v
      setMinutesS
    • v
      setMinutesSMs
    • v
      setMonth
    • v
      setMonthD
    • v
      setSeconds
    • v
      setSecondsMs
    • v
      setTime
    • v
      setUTCDate
    • v
      setUTCFullYear
    • v
      setUTCFullYearM
    • v
      setUTCFullYearMD
    • v
      setUTCHours
    • v
      setUTCHoursM
    • v
      setUTCHoursMS
    • v
      setUTCHoursMSMs
    • v
      setUTCMilliseconds
    • v
      setUTCMinutes
    • v
      setUTCMinutesS
    • v
      setUTCMinutesSMs
    • v
      setUTCMonth
    • v
      setUTCMonthD
    • v
      setUTCSeconds
    • v
      setUTCSecondsMs
    • v
      setUTCTime
    • v
      setYear
      D
    • v
      toDateString
    • v
      toGMTString
      D
    • v
      toISOString
    • v
      toJSON
      D
    • v
      toJSONUnsafe
    • v
      toLocaleDateString
    • v
      toLocaleString
    • v
      toLocaleTimeString
    • v
      toString
    • v
      toTimeString
    • v
      toUTCString
  • Dict
  • Exn
  • File
  • Float
  • Global
  • Int
  • Json
    • Kind
  • List
  • Map
  • Math
  • Null
  • Null_undefined
  • Nullable
  • Obj
  • Option
  • Promise
  • Promise2
  • Re
  • Result
  • Set
  • String
  • String2
  • TypedArray2
    • DataView
    • Float64Array
    • Float32Array
    • Uint32Array
    • Int32Array
    • Uint16Array
    • Int16Array
    • Uint8ClampedArray
    • Uint8Array
    • Int8Array
    • ArrayBuffer
    Typed_array
    • DataView
    • Float64_array
    • Float64Array
    • Float32_array
    • Float32Array
    • Uint32Array
    • Int32_array
    • Int32Array
    • Uint16Array
    • Int16Array
    • Uint8ClampedArray
    • Uint8Array
    • Int8Array
    • S
    • ArrayBuffer
    • Type
  • Types
  • Undefined
  • Vector
  • WeakMap
  • WeakSet
  • API / Js / Date

    Date

    Provide bindings to JS date. (See Date on MDN.) JavaScript stores dates as the number of milliseconds since the UNIX epoch, midnight 1 January 1970, UTC.

    t

    RESCRIPT
    type t

    valueOf

    RESCRIPT
    let valueOf: t => float

    Returns the primitive value of this date, equivalent to getTime(). (See Date.valueOf on MDN.)

    Examples

    RESCRIPT
    Js.Date.valueOf(exampleDate) == 123456654321.0

    make

    RESCRIPT
    let make: unit => t

    Returns a date representing the current time. See Date() Constructor on MDN.

    Examples

    RESCRIPT
    let now = Js.Date.make()

    fromFloat

    RESCRIPT
    let fromFloat: float => t

    Returns a date representing the given argument, which is a number of milliseconds since the epoch. See Date() Constructor on MDN.

    Examples

    RESCRIPT
    Js.Date.fromFloat(123456654321.0) == exampleDate

    fromString

    RESCRIPT
    let fromString: string => t

    Returns a Js.Date.t represented by the given string. The string can be in “IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.” Returns NaN if given an invalid date string. According to the Date() Constructor documentation on MDN, its use is discouraged.

    Examples

    RESCRIPT
    Js.Date.fromString("Thu, 29 Nov 1973 21:30:54.321 GMT") == exampleDate Js.Date.fromString("1973-11-29T21:30:54.321Z00:00") == exampleDate Js.Date.fromString("Thor, 32 Lok -19 60:70:80 XYZ") // returns NaN

    makeWithYM

    RESCRIPT
    let makeWithYM: (~year: float, ~month: float, unit) => t

    Returns a date representing midnight of the first day of the given month and year in the current time zone. Fractional parts of arguments are ignored. See Date() Constructor on MDN.

    Examples

    RESCRIPT
    let november1 = Js.Date.makeWithYM(~year=2020.0, ~month=10.0, ())

    makeWithYMD

    RESCRIPT
    let makeWithYMD: (~year: float, ~month: float, ~date: float, unit) => t

    Returns a date representing midnight of the given date of the given month and year in the current time zone. Fractional parts of arguments are ignored. See Date() Constructor on MDN.

    makeWithYMDH

    RESCRIPT
    let makeWithYMDH: ( ~year: float, ~month: float, ~date: float, ~hours: float, unit, ) => t

    Returns a date representing the given date of the given month and year, at zero minutes and zero seconds past the given hours, in the current time zone. Fractional parts of arguments are ignored. See Date() Constructor on MDN. Fractional parts of the arguments are ignored.

    makeWithYMDHM

    RESCRIPT
    let makeWithYMDHM: ( ~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, unit, ) => t

    Returns a date representing the given date of the given month and year, at zero seconds past the given time in hours and minutes in the current time zone. Fractional parts of arguments are ignored. See Date() Constructor on MDN.

    makeWithYMDHMS

    RESCRIPT
    let makeWithYMDHMS: ( ~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, ~seconds: float, unit, ) => t

    Returns a date representing the given date of the given month and year, at the given time in hours, minutes, and seconds in the current time zone. Fractional parts of arguments are ignored. See Date() Constructor on MDN.

    Examples

    RESCRIPT
    Js.Date.makeWithYMDHMS( ~year=1973.0, ~month=11.0, ~date=29.0, ~hours=21.0, ~minutes=30.0, ~seconds=54.321, (), ) == exampleDate

    utcWithYM

    RESCRIPT
    let utcWithYM: (~year: float, ~month: float, unit) => float

    Returns a float representing the number of milliseconds past the epoch for midnight of the first day of the given month and year in UTC. Fractional parts of arguments are ignored. See Date.UTC on MDN.

    Examples

    RESCRIPT
    let november1 = Js.Date.utcWithYM(~year=2020.0, ~month=10.0, ())

    utcWithYMD

    RESCRIPT
    let utcWithYMD: (~year: float, ~month: float, ~date: float, unit) => float

    Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year in UTC. Fractional parts of arguments are ignored. See Date.UTC on MDN.

    utcWithYMDH

    RESCRIPT
    let utcWithYMDH: ( ~year: float, ~month: float, ~date: float, ~hours: float, unit, ) => float

    Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year, at zero minutes and seconds past the given hours in UTC. Fractional parts of arguments are ignored. See Date.UTC on MDN.

    utcWithYMDHM

    RESCRIPT
    let utcWithYMDHM: ( ~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, unit, ) => float

    Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year, at zero seconds past the given number of minutes past the given hours in UTC. Fractional parts of arguments are ignored. See Date.UTC on MDN.

    utcWithYMDHMS

    RESCRIPT
    let utcWithYMDHMS: ( ~year: float, ~month: float, ~date: float, ~hours: float, ~minutes: float, ~seconds: float, unit, ) => float

    Returns a float representing the number of milliseconds past the epoch for midnight of the given date of the given month and year, at the given time in hours, minutes and seconds in UTC. Fractional parts of arguments are ignored.

    See Date.UTC on MDN.

    now

    RESCRIPT
    let now: unit => float

    Returns the current time as number of milliseconds since Unix epoch.

    parse

    Deprecated

    Please use fromString instead

    RESCRIPT
    let parse: string => t

    parseAsFloat

    RESCRIPT
    let parseAsFloat: string => float

    Returns a float with the number of milliseconds past the epoch represented by the given string. The string can be in “IETF-compliant RFC 2822 timestamps, and also strings in a version of ISO8601.” Returns NaN if given an invalid date string. According to the Date.parse documentation on MDN, its use is discouraged. Returns NaN if passed invalid date string.

    getDate

    RESCRIPT
    let getDate: t => float

    Returns the day of the month for its argument. The argument is evaluated in the current time zone. See Date.getDate on MDN.

    Examples

    RESCRIPT
    Js.Date.getDate(exampleDate) == 29.0

    getDay

    RESCRIPT
    let getDay: t => float

    Returns the day of the week (0.0-6.0) for its argument, where 0.0 represents Sunday. The argument is evaluated in the current time zone. See Date.getDay on MDN.

    Examples

    RESCRIPT
    Js.Date.getDay(exampleDate) == 4.0

    getFullYear

    RESCRIPT
    let getFullYear: t => float

    Returns the full year (as opposed to the range 0-99) for its argument. The argument is evaluated in the current time zone. See Date.getFullYear on MDN.

    Examples

    RESCRIPT
    Js.Date.getFullYear(exampleDate) == 1973.0

    getHours

    RESCRIPT
    let getHours: t => float

    Returns the hours for its argument, evaluated in the current time zone. See Date.getHours on MDN.

    Examples

    RESCRIPT
    Js.Date.getHours(exampleDate) == 22.0 // Vienna is in GMT+01:00

    getMilliseconds

    RESCRIPT
    let getMilliseconds: t => float

    Returns the number of milliseconds for its argument, evaluated in the current time zone. See Date.getMilliseconds on MDN.

    Examples

    RESCRIPT
    Js.Date.getMilliseconds(exampleDate) == 321.0

    getMinutes

    RESCRIPT
    let getMinutes: t => float

    Returns the number of minutes for its argument, evaluated in the current time zone. See Date.getMinutes on MDN.

    Examples

    RESCRIPT
    Js.Date.getMinutes(exampleDate) == 30.0

    getMonth

    RESCRIPT
    let getMonth: t => float

    Returns the month (0.0-11.0) for its argument, evaluated in the current time zone. January is month zero. See Date.getMonth on MDN.

    Examples

    RESCRIPT
    Js.Date.getMonth(exampleDate) == 10.0

    getSeconds

    RESCRIPT
    let getSeconds: t => float

    Returns the seconds for its argument, evaluated in the current time zone. See Date.getSeconds on MDN.

    Examples

    RESCRIPT
    Js.Date.getSeconds(exampleDate) == 54.0

    getTime

    RESCRIPT
    let getTime: t => float

    Returns the number of milliseconds since Unix epoch, evaluated in UTC. See Date.getTime on MDN.

    Examples

    RESCRIPT
    Js.Date.getTime(exampleDate) == 123456654321.0

    getTimezoneOffset

    RESCRIPT
    let getTimezoneOffset: t => float

    Returns the time zone offset in minutes from the current time zone to UTC. See Date.getTimezoneOffset on MDN.

    Examples

    RESCRIPT
    Js.Date.getTimezoneOffset(exampleDate) == -60.0

    getUTCDate

    RESCRIPT
    let getUTCDate: t => float

    Returns the day of the month of the argument, evaluated in UTC. See Date.getUTCDate on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCDate(exampleDate) == 29.0

    getUTCDay

    RESCRIPT
    let getUTCDay: t => float

    Returns the day of the week of the argument, evaluated in UTC. The range of the return value is 0.0-6.0, where Sunday is zero. See Date.getUTCDay on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCDay(exampleDate) == 4.0

    getUTCFullYear

    RESCRIPT
    let getUTCFullYear: t => float

    Returns the full year (as opposed to the range 0-99) for its argument. The argument is evaluated in UTC. See Date.getUTCFullYear on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCFullYear(exampleDate) == 1973.0

    getUTCHours

    RESCRIPT
    let getUTCHours: t => float

    Returns the hours for its argument, evaluated in the current time zone. See Date.getUTCHours on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCHours(exampleDate) == 21.0

    getUTCMilliseconds

    RESCRIPT
    let getUTCMilliseconds: t => float

    Returns the number of milliseconds for its argument, evaluated in UTC. See Date.getUTCMilliseconds on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCMilliseconds(exampleDate) == 321.0

    getUTCMinutes

    RESCRIPT
    let getUTCMinutes: t => float

    Returns the number of minutes for its argument, evaluated in UTC. See Date.getUTCMinutes on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCMinutes(exampleDate) == 30.0

    getUTCMonth

    RESCRIPT
    let getUTCMonth: t => float

    Returns the month (0.0-11.0) for its argument, evaluated in UTC. January is month zero. See Date.getUTCMonth on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCMonth(exampleDate) == 10.0

    getUTCSeconds

    RESCRIPT
    let getUTCSeconds: t => float

    Returns the seconds for its argument, evaluated in UTC. See Date.getUTCSeconds on MDN.

    Examples

    RESCRIPT
    Js.Date.getUTCSeconds(exampleDate) == 54.0

    getYear

    Deprecated

    Use getFullYear instead.

    RESCRIPT
    let getYear: t => float

    setDate

    RESCRIPT
    let setDate: (t, float) => float

    Sets the given Date’s day of month to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setDate on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let twoWeeksBefore = Js.Date.setDate(date1, 15.0) date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00") twoWeeksBefore == Js.Date.getTime(date1)

    setFullYear

    RESCRIPT
    let setFullYear: (t, float) => float

    Sets the given Date’s year to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setFullYear on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let nextYear = Js.Date.setFullYear(date1, 1974.0) date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00") nextYear == Js.Date.getTime(date1)

    setFullYearM

    RESCRIPT
    let setFullYearM: (t, ~year: float, ~month: float, unit) => float

    Sets the given Date’s year and month to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setFullYear on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let future = Js.Date.setFullYearM(date1, ~year=1974.0, ~month=0.0, ()) date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00") future == Js.Date.getTime(date1)

    setFullYearMD

    RESCRIPT
    let setFullYearMD: ( t, ~year: float, ~month: float, ~date: float, unit, ) => float

    Sets the given Date’s year, month, and day of month to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setFullYear on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let future = Js.Date.setFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ()) date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00") future == Js.Date.getTime(date1)

    setHours

    RESCRIPT
    let setHours: (t, float) => float

    Sets the given Date’s hours to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let nextHour = Js.Date.setHours(date1, 22.0) date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00") nextHour == Js.Date.getTime(date1)

    setHoursM

    RESCRIPT
    let setHoursM: (t, ~hours: float, ~minutes: float, unit) => float

    Sets the given Date’s hours and minutes to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setHoursM(date1, ~hours=22.0, ~minutes=46.0, ()) date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00") futureTime == Js.Date.getTime(date1)

    setHoursMS

    RESCRIPT
    let setHoursMS: ( t, ~hours: float, ~minutes: float, ~seconds: float, unit, ) => float

    Sets the given Date’s hours, minutes, and seconds to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ()) date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00") futureTime == Js.Date.getTime(date1)

    setHoursMSMs

    RESCRIPT
    let setHoursMSMs: ( t, ~hours: float, ~minutes: float, ~seconds: float, ~milliseconds: float, unit, ) => float

    Sets the given Date’s hours, minutes, seconds, and milliseconds to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setHoursMSMs( date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ~milliseconds=494.0, (), ) date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00") futureTime == Js.Date.getTime(date1)

    setMilliseconds

    RESCRIPT
    let setMilliseconds: (t, float) => float

    Sets the given Date’s milliseconds to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setMilliseconds on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setMilliseconds(date1, 494.0) date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00") futureTime == Js.Date.getTime(date1)

    setMinutes

    RESCRIPT
    let setMinutes: (t, float) => float

    Sets the given Date’s minutes to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setMinutes on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setMinutes(date1, 34.0) date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00") futureTime == Js.Date.getTime(date1)

    setMinutesS

    RESCRIPT
    let setMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float

    Sets the given Date’s minutes and seconds to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setMinutes on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ()) date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00") futureTime == Js.Date.getTime(date1)

    setMinutesSMs

    RESCRIPT
    let setMinutesSMs: ( t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit, ) => float

    Sets the given Date’s minutes, seconds, and milliseconds to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setMinutes on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setMinutesSMs( date1, ~minutes=34.0, ~seconds=56.0, ~milliseconds=789.0, (), ) date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setMonth

    RESCRIPT
    let setMonth: (t, float) => float

    Sets the given Date’s month to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setMonth on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setMonth(date1, 11.0) date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setMonthD

    RESCRIPT
    let setMonthD: (t, ~month: float, ~date: float, unit) => float

    Sets the given Date’s month and day of month to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setMonth on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setMonthD(date1, ~month=11.0, ~date=8.0, ()) date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setSeconds

    RESCRIPT
    let setSeconds: (t, float) => float

    Sets the given Date’s seconds to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setSeconds on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setSeconds(date1, 56.0) date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00") futureTime == Js.Date.getTime(date1)

    setSecondsMs

    RESCRIPT
    let setSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float

    Sets the given Date’s seconds and milliseconds to the values in the labeled arguments according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setSeconds on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ()) date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setTime

    RESCRIPT
    let setTime: (t, float) => float

    Sets the given Date’s value in terms of milliseconds since the epoch. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setTime on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setTime(date1, 198765432101.0) date1 == Js.Date.fromString("1976-04-19T12:37:12.101Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCDate

    RESCRIPT
    let setUTCDate: (t, float) => float

    Sets the given Date’s day of month to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCDate on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let twoWeeksBefore = Js.Date.setUTCDate(date1, 15.0) date1 == Js.Date.fromString("1973-11-15T21:30:54.321Z00:00") twoWeeksBefore == Js.Date.getTime(date1)

    setUTCFullYear

    RESCRIPT
    let setUTCFullYear: (t, float) => float

    Sets the given Date’s year to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCFullYear on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let nextYear = Js.Date.setUTCFullYear(date1, 1974.0) date1 == Js.Date.fromString("1974-11-15T21:30:54.321Z00:00") nextYear == Js.Date.getTime(date1)

    setUTCFullYearM

    RESCRIPT
    let setUTCFullYearM: (t, ~year: float, ~month: float, unit) => float

    Sets the given Date’s year and month to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCFullYear on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let future = Js.Date.setUTCFullYearM(date1, ~year=1974.0, ~month=0.0, ()) date1 == Js.Date.fromString("1974-01-22T21:30:54.321Z00:00") future == Js.Date.getTime(date1)

    setUTCFullYearMD

    RESCRIPT
    let setUTCFullYearMD: ( t, ~year: float, ~month: float, ~date: float, unit, ) => float

    Sets the given Date’s year, month, and day of month to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCFullYear on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let future = Js.Date.setUTCFullYearMD(date1, ~year=1974.0, ~month=0.0, ~date=7.0, ()) date1 == Js.Date.fromString("1974-01-07T21:30:54.321Z00:00") future == Js.Date.getTime(date1)

    setUTCHours

    RESCRIPT
    let setUTCHours: (t, float) => float

    Sets the given Date’s hours to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let nextHour = Js.Date.setUTCHours(date1, 22.0) date1 == Js.Date.fromString("1973-11-29T22:30:54.321Z00:00") nextHour == Js.Date.getTime(date1)

    setUTCHoursM

    RESCRIPT
    let setUTCHoursM: (t, ~hours: float, ~minutes: float, unit) => float

    Sets the given Date’s hours and minutes to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCHoursM(date1, ~hours=22.0, ~minutes=46.0, ()) date1 == Js.Date.fromString("1973-11-29T22:46:54.321Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCHoursMS

    RESCRIPT
    let setUTCHoursMS: ( t, ~hours: float, ~minutes: float, ~seconds: float, unit, ) => float

    Sets the given Date’s hours, minutes, and seconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date.

    See Date.setUTCHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCHoursMS(date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ()) date1 == Js.Date.fromString("1973-11-29T22:46:37.321Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCHoursMSMs

    RESCRIPT
    let setUTCHoursMSMs: ( t, ~hours: float, ~minutes: float, ~seconds: float, ~milliseconds: float, unit, ) => float

    Sets the given Date’s hours, minutes, seconds, and milliseconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCHours on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCHoursMSMs( date1, ~hours=22.0, ~minutes=46.0, ~seconds=37.0, ~milliseconds=494.0, (), ) date1 == Js.Date.fromString("1973-11-29T22:46:37.494Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCMilliseconds

    RESCRIPT
    let setUTCMilliseconds: (t, float) => float

    Sets the given Date’s milliseconds to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCMilliseconds on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCMilliseconds(date1, 494.0) date1 == Js.Date.fromString("1973-11-29T21:30:54.494Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCMinutes

    RESCRIPT
    let setUTCMinutes: (t, float) => float

    Sets the given Date’s minutes to the value in the second argument according to the current time zone. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCMinutes on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCMinutes(date1, 34.0) date1 == Js.Date.fromString("1973-11-29T21:34:54.494Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCMinutesS

    RESCRIPT
    let setUTCMinutesS: (t, ~minutes: float, ~seconds: float, unit) => float

    Sets the given Date’s minutes and seconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCMinutes on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCMinutesS(date1, ~minutes=34.0, ~seconds=56.0, ()) date1 == Js.Date.fromString("1973-11-29T21:34:56.494Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCMinutesSMs

    RESCRIPT
    let setUTCMinutesSMs: ( t, ~minutes: float, ~seconds: float, ~milliseconds: float, unit, ) => float

    Sets the given Date’s minutes, seconds, and milliseconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCMinutes on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCMinutesSMs( date1, ~minutes=34.0, ~seconds=56.0, ~milliseconds=789.0, (), ) date1 == Js.Date.fromString("1973-11-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCMonth

    RESCRIPT
    let setUTCMonth: (t, float) => float

    Sets the given Date’s month to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCMonth on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCMonth(date1, 11.0) date1 == Js.Date.fromString("1973-12-29T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCMonthD

    RESCRIPT
    let setUTCMonthD: (t, ~month: float, ~date: float, unit) => float

    Sets the given Date’s month and day of month to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCMonth on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCMonthD(date1, ~month=11.0, ~date=8.0, ()) date1 == Js.Date.fromString("1973-12-08T21:34:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCSeconds

    RESCRIPT
    let setUTCSeconds: (t, float) => float

    Sets the given Date’s seconds to the value in the second argument according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCSeconds on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCSeconds(date1, 56.0) date1 == Js.Date.fromString("1973-12-29T21:30:56.321Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCSecondsMs

    RESCRIPT
    let setUTCSecondsMs: (t, ~seconds: float, ~milliseconds: float, unit) => float

    Sets the given Date’s seconds and milliseconds to the values in the labeled arguments according to UTC. Returns the number of milliseconds since the epoch of the updated Date. This function modifies the original Date. See Date.setUTCSeconds on MDN.

    Examples

    RESCRIPT
    let date1 = Js.Date.fromFloat(123456654321.0) // 29 November 1973 21:30:54.321 GMT let futureTime = Js.Date.setUTCSecondsMs(date1, ~seconds=56.0, ~milliseconds=789.0, ()) date1 == Js.Date.fromString("1973-12-29T21:30:56.789Z00:00") futureTime == Js.Date.getTime(date1)

    setUTCTime

    RESCRIPT
    let setUTCTime: (t, float) => float

    Same as setTime().

    setYear

    Deprecated

    Use setFullYear instead

    RESCRIPT
    let setYear: (t, float) => float

    toDateString

    RESCRIPT
    let toDateString: t => string

    Returns the date (day of week, year, month, and day of month) portion of a Date in English. See Date.toDateString on MDN.

    Examples

    RESCRIPT
    Js.Date.toDateString(exampleDate) == "Thu Nov 29 1973"

    toGMTString

    Deprecated

    Use toUTCString instead

    RESCRIPT
    let toGMTString: t => string

    toISOString

    RESCRIPT
    let toISOString: t => string

    Returns a simplified version of the ISO 8601 format for the date. See Date.toISOString on MDN.

    Examples

    RESCRIPT
    Js.Date.toISOString(exampleDate) == "1973-11-29T21:30:54.321Z"

    toJSON

    Deprecated

    This method is unsafe. It will be changed to return option in a future
    release. Please use toJSONUnsafe instead.

    RESCRIPT
    let toJSON: t => string

    toJSONUnsafe

    RESCRIPT
    let toJSONUnsafe: t => string

    Returns a string representation of the given date. See Date.toJSON on MDN.

    toLocaleDateString

    RESCRIPT
    let toLocaleDateString: t => string

    Returns the year, month, and day for the given Date in the current locale format. See Date.toLocaleDateString on MDN.

    Examples

    RESCRIPT
    Js.Date.toLocaleDateString(exampleDate) == "11/29/1973" // for en_US.utf8 Js.Date.toLocaleDateString(exampleDate) == "29.11.73" // for de_DE.utf8

    toLocaleString

    RESCRIPT
    let toLocaleString: t => string

    Returns the time and date for the given Date in the current locale format. See Date.toLocaleString on MDN.

    Examples

    RESCRIPT
    Js.Date.toLocaleString(exampleDate) == "11/29/1973, 10:30:54 PM" // for en_US.utf8 Js.Date.toLocaleString(exampleDate) == "29.11.1973, 22:30:54" // for de_DE.utf8

    toLocaleTimeString

    RESCRIPT
    let toLocaleTimeString: t => string

    Returns the time of day for the given Date in the current locale format. See Date.toLocaleTimeString on MDN.

    Examples

    RESCRIPT
    Js.Date.toLocaleString(exampleDate) == "10:30:54 PM" // for en_US.utf8 Js.Date.toLocaleString(exampleDate) == "22:30:54" // for de_DE.utf8

    toString

    RESCRIPT
    let toString: t => string

    Returns a string representing the date and time of day for the given Date in the current locale and time zone. See Date.toString on MDN.

    Examples

    RESCRIPT
    Js.Date.toString( exampleDate, ) == "Thu Nov 29 1973 22:30:54 GMT+0100 (Central European Standard Time)"

    toTimeString

    RESCRIPT
    let toTimeString: t => string

    Returns a string representing the time of day for the given Date in the current locale and time zone. See Date.toTimeString on MDN.

    Examples

    RESCRIPT
    Js.Date.toTimeString(exampleDate) == "22:30:54 GMT+0100 (Central European Standard Time)"

    toUTCString

    RESCRIPT
    let toUTCString: t => string

    Returns a string representing the date and time of day for the given Date in the current locale and UTC (GMT time zone). See Date.toUTCString on MDN.

    Examples

    RESCRIPT
    Js.Date.toUTCString(exampleDate) == "Thu, 29 Nov 1973 21:30:54 GMT"
    Types and values
    • t
      t
    • v
      valueOf
    • v
      make
    • v
      fromFloat
    • v
      fromString
    • v
      makeWithYM
    • v
      makeWithYMD
    • v
      makeWithYMDH
    • v
      makeWithYMDHM
    • v
      makeWithYMDHMS
    • v
      utcWithYM
    • v
      utcWithYMD
    • v
      utcWithYMDH
    • v
      utcWithYMDHM
    • v
      utcWithYMDHMS
    • v
      now
    • v
      parse
      D
    • v
      parseAsFloat
    • v
      getDate
    • v
      getDay
    • v
      getFullYear
    • v
      getHours
    • v
      getMilliseconds
    • v
      getMinutes
    • v
      getMonth
    • v
      getSeconds
    • v
      getTime
    • v
      getTimezoneOffset
    • v
      getUTCDate
    • v
      getUTCDay
    • v
      getUTCFullYear
    • v
      getUTCHours
    • v
      getUTCMilliseconds
    • v
      getUTCMinutes
    • v
      getUTCMonth
    • v
      getUTCSeconds
    • v
      getYear
      D
    • v
      setDate
    • v
      setFullYear
    • v
      setFullYearM
    • v
      setFullYearMD
    • v
      setHours
    • v
      setHoursM
    • v
      setHoursMS
    • v
      setHoursMSMs
    • v
      setMilliseconds
    • v
      setMinutes
    • v
      setMinutesS
    • v
      setMinutesSMs
    • v
      setMonth
    • v
      setMonthD
    • v
      setSeconds
    • v
      setSecondsMs
    • v
      setTime
    • v
      setUTCDate
    • v
      setUTCFullYear
    • v
      setUTCFullYearM
    • v
      setUTCFullYearMD
    • v
      setUTCHours
    • v
      setUTCHoursM
    • v
      setUTCHoursMS
    • v
      setUTCHoursMSMs
    • v
      setUTCMilliseconds
    • v
      setUTCMinutes
    • v
      setUTCMinutesS
    • v
      setUTCMinutesSMs
    • v
      setUTCMonth
    • v
      setUTCMonthD
    • v
      setUTCSeconds
    • v
      setUTCSecondsMs
    • v
      setUTCTime
    • v
      setYear
      D
    • v
      toDateString
    • v
      toGMTString
      D
    • v
      toISOString
    • v
      toJSON
      D
    • v
      toJSONUnsafe
    • v
      toLocaleDateString
    • v
      toLocaleString
    • v
      toLocaleTimeString
    • v
      toString
    • v
      toTimeString
    • v
      toUTCString

    © 2024 The ReScript Project

    Software and assets distribution powered by KeyCDN.

    About
    • Community
    • ReScript Association
    Find us on