Today, in the format of the time, under the IE8 browser encountered a problem of Nan. But there is no problem on the chorme.
Debugging was found to be an issue with parameters passed in the date () method.
After looking for other people's information, especially this article.
Http://www.jb51.net/article/29800.htm.
Find out where the problem lies. But there is a small problem in it.
function Newdate (str) {str = str.split ('-'); var date = new Date (); Date.setutcfullyear (Str[0], str[1]-1, str[2]); Date.setutchours (0, 0, 0, 0); return date; }
The default incoming join for STR should be 2015-05-06. It will only be solved if there is a year and a half.
If you want to format only month or year.
You should:
Date.setutcfullyear (Str[0], str[1]-1, str[2]);
Change the parameters to 2 or 1.
Date.setutchours (0, 0, 0, 0);
This sentence depends on your own needs.
This article is from the "work history of the Mo Bo" blog, please be sure to keep this source http://moxiaobo.blog.51cto.com/6784434/1643452
A case of Nan occurs with the date () method under IE.