Skip to content

Latest commit

 

History

History

dates-and-times

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

JavaScript - Dates & Times

Date class is used to create the time and date.

  • Syntax:
    const today = new Date(); // creates today date and time
    const dateFromTimestamp = new Date(1677733088145); // creates date and time by timestamp

Methods

  • getFullYear() - returns the year
  • getMonth() - returns the index of month
  • getDay() - returns the index of day
  • getDate() - returns the date
  • getTime() - returns the timestamp
  • getHours() - returns the hours
  • getMinutes() - returns the minutes
  • getSeconds() - returns the seconds
  • toDateString() - returns the date string
  • toTimeString() - returns the time string