I am trying to get the timestamp of what would be 16:00 UTC of the following date. Here's my code:
const date = new Date()
console.log(Date.UTC(date.getFullYear, date.getMonth, date.getDate 1, 16)) //NaN
This seems to work fine if I only pass hard coded numbers:
console.log(Date.UTC(2022, 0, 24, 16)) //1643040000000
Am I doing something wrong here?
CodePudding user response:
getFullYear(), getMonth() & getDate() are methods
const date = new Date()
console.log(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate() 1, 16))
CodePudding user response:
everything is right except the way you log it on console
const d = new Date();
let day = d.getUTCDate();
For example:
console.log(d.UTC(d.getFullYear())
CodePudding user response:
const date = new Date()
Now use these methods
----------------------
date.getFullYear()
date.getMonth()
date.getDate()
