Why does JavaScript show me one day before my set date?

This question already has an answer here:

  • Javascript date object always one day off? 14 answers

  • When you create date from string without timezone you get a date + timezone correction – if you're in USA then you have something like GMT-7 and you get the second of June minus 7 hours – the previous day. Try splitting your date and use new Date(2015, 7, 1) constructor and you'll get date you're expecting. String parse reference docs -https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date/parse

    链接地址: http://www.djcxy.com/p/28860.html

    上一篇: 关于Java规范的理解困难

    下一篇: 为什么JavaScript会在我设定的日期前一天显示给我?