Search code examples
jquerydateutciso

jquery converting to utc and iso date


I am converting a date to utc and iso in jquery but always it returns one month after after the date that i gave, here is my code

var x = new Date(2015,09,1).toISOString();

and here is the result

x = "2015-09-30T21:00:00.000Z"

for UTC also returns one month after.any help thanks


Solution

  • Date starts from zero (0) ,so you should subtract 1 to get actual date...means for 0 corresponding to January in date