This article is a mirror article of machine translation, please click here to jump to the original article.

View: 10231|Reply: 1

[Jquery] Jquery formats /Date(1356969600000)/ into the time format of the year, month, day

[Copy link]
Posted on 11/3/2015 6:15:16 PM | | | |


The date json gets "/Date(-2209017600000)/", this problem, the front desk can't see this thing for others???

Then I didn't find a suitable method in Baidu, and then summarized it from it and got the code:

  1. var datetime = new Date(parseInt(data.replace("/Date(", "").replace(")/", ""), 10));
  2.                             var year = datetime.getFullYear();
  3.                             var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
  4.                             var currentDate = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
  5.                             var hour = datetime.getHours() < 10 ? "0" + datetime.getHours() : datetime.getHours();
  6.                             var minute = datetime.getMinutes() < 10 ? "0" + datetime.getMinutes() : datetime.getMinutes();
  7.                             var second = datetime.getSeconds() < 10 ? "0" + datetime.getSeconds() : datetime.getSeconds();
  8.                             return year + "-" + month + "-" + currentDate + " " + hour + ":" + minute + ":" + second;
Copy code
data in it.




Previous:Regarding ternary operators, there is an error that cannot determine the type of conditional expression
Next:C# gets the CPU and memory information of the system
 Landlord| Posted on 7/12/2016 5:56:40 PM |
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com