showing results for - "date utc end of month"
Sara
21 May 2016
1  //TODAY is the 16th of OCTOBER 2020
2  var date = new Date();
3  var year = date.getMonth() < 11 ? date.getFullYear() : date.getFullYear() + 1;
4  var month = date.getMonth() < 11 ? date.getMonth() + 1 : 0;
5
6  // toUTCString() to display a local time in utc string
7  console.log(new Date(Date.UTC(year, month)).toUTCString());
8		//Sun, 01 Nov 2020 00:00:00 GMT
9  var utcYear = date.getUTCMonth() < 11 ? date.getUTCFullYear() : date.getUTCFullYear() + 1;
10  var utcMonth = date.getUTCMonth() < 11 ? date.getUTCMonth() + 1 : 0;
11  
12  // toString() do not change datetime
13  console.log(new Date(utcYear, utcMonth));
14  		//22 Sun Nov 01 2020 00:00:00 GMT+0100 (Ora standard dell’Europa centrale)