Announcement

Collapse
No announcement yet.

getUTCMonth returns the wrong month

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • getUTCMonth returns the wrong month

    Has anyone got a fix for the date object, when i use the below, it returns the wrong month ie it returns 10 when it should be 11

    var CurrentMonth = today.getUTCMonth();

    below is the code i use, maybe it has an issue, any ideas?

    var today = new Date();
    var hours = today.getUTCHours();
    var CurrentDate = today.getUTCDate()
    var CurrentMonth = today.getUTCMonth();
    var minutes = today.getUTCMinutes();?

  • #2
    That is how Javascript months work. 0-11
    Add +1 to today.getUTCMonth(); and you'll get the desired month. Not a fan of this either, but that's Javascript for you

    https://developer.mozilla.org/en-US/.../Date/getMonth
    Last edited by ewdeg98; 11-06-2023, 10:14 PM.

    Comment

    Working...
    X