Javascript Date: next month

后端 未结 8 1452
情深已故
情深已故 2020-11-28 10:01

I\'ve been using Javascript\'s Date for a project, but noticed today that my code that previously worked is no longer working correctly. Instead of producing Feb as expected

8条回答
  •  暖寄归人
    2020-11-28 10:30

    try this:

    var a = screen.Data.getFullYear();
    var m = screen.Data.getMonth();
    var d = screen.Data.getDate();
    
    m = m + 1;
    screen.Data = new Date(a, m, d);
    
    if (screen.Data.getDate() != d)
    screen.Data = new Date(a, m + 1, 0);
    

提交回复
热议问题