Date Time - Javascript

  • let var = new Date() => Returns current date and time and day in IST
  • new Date(0) => Returns date and time of Jan 1st 1970 5:30:00
  • new Date(n) => Returns date and time by adding n millisecond to Jan 1st 1970 5:30:00
  • new Date("2021-01-01") => Returns date and day of that day
  • new Date(year, month, date, hours, minutes, seconds) => Returns date of given information
  • var.getFullYear()
  • var.getDay()
  • var.getMonth()
  • var.getDate()
  • var.getMinutes()
  • var.getSeconds()
  • var.getHours()
  • var.setDate(n)
  • var.setHours(n)
  • var.setMinutes(n)
  • var.toLocaleTimeString()
  • Date.now() => Returns Number of milliseconds passed since Jan 1 1970, 5:30:01
Share: