Josh BucheaNotes

JavaScript Date

const now = new Date();

Methods

MethodValueDescription
now.toDateString()Fri Jan 24 2020Converts the date portion of a Date object into a readable string
now.toISOString()2020-01-24T05:32:29.607ZReturns the date as a string, using the ISO standard
now.toJSON()2020-01-24T05:32:29.607ZReturns the date as a string, formatted as a JSON date
now.toLocaleDateString()1/24/2020Returns the date portion of a Date object as a string, using locale conventions
now.toLocaleTimeString()5:32:29 AMReturns the time portion of a Date object as a string, using locale conventions
now.toLocaleString()1/24/2020, 5:32:29 AMConverts a Date object to a string, using locale conventions
now.toString()Fri Jan 24 2020 05:32:29 GMT+0000 (Coordinated Universal Time)Converts a Date object to a string
now.toTimeString()05:32:29 GMT+0000 (Coordinated Universal Time)Converts the time portion of a Date object to a string
now.toUTCString()Fri, 24 Jan 2020 05:32:29 GMTConverts a Date object to a string, according to universal time
now.getDate()24Returns the day of the month (from 1-31)
now.getDay()5Returns the day of the week (from 0-6)
now.getFullYear()2020Returns the year
now.getHours()5Returns the hour (from 0-23)
now.getMilliseconds()607Returns the milliseconds (from 0-999)
now.getMinutes()32Returns the minutes (from 0-59)
now.getMonth()0Returns the month (from 0-11)
now.getSeconds()29Returns the seconds (from 0-59)
now.getTime()1579843949607Returns the number of milliseconds since midnight Jan 1 1970, and a specified date
now.getTimezoneOffset()0Returns the time difference between UTC time and local time, in minutes
now.getUTCDate()24Returns the day of the month, according to universal time (from 1-31)
now.getUTCDay()5Returns the day of the week, according to universal time (from 0-6)
now.getUTCFullYear()2020Returns the year, according to universal time
now.getUTCHours()5Returns the hour, according to universal time (from 0-23)
now.getUTCMilliseconds()607Returns the milliseconds, according to universal time (from 0-999)
now.getUTCMinutes()32Returns the minutes, according to universal time (from 0-59)
now.getUTCSeconds()29Returns the seconds, according to universal time (from 0-59)
now.valueOf()1579843949607Returns the primitive value of a Date object
Date.now()1579843949615Returns the number of milliseconds since midnight Jan 1, 1970
Date.parse('Fri Jan 24 2020')1579824000000Parses a date string and returns the number of milliseconds since January 1, 1970
Date.UTC( 2020, 0, 5, 5, 32, 29, 607, 1578202349607Accepts the same parameters as the Date constructor, but treats them as UTC. Returns the number of milliseconds since January 1, 1970, 00:00:00 UTC.
Follow me on Twitter

Get email updates and announcements