.getUTCMonth()

thisispetrus1 total contribution
Published Jun 15, 2023
Contribute to Docs
Get methods are used to retrieve date components based on the user’s local timezone settings. The .getUTCMonth()
method returns the month of the date passed, similar to .getMonth()
. However, .getUTCMonth()
calculates the time based on the UTC (Coordinated Universal Time) standard.
Syntax
const today = new Date();
const month = today.getUTCMonth();
Example above assigns the month portion of the current Date
to the variable month
.
Example
const date1 = new Date('December 31, 1975, 23:15:30 GMT+11:00');const date2 = new Date('December 31, 1975, 23:15:30 GMT-11:00');console.log(date1.getUTCMonth());console.log(date2.getUTCMonth());
This results in the following output:
110
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.