对日期字符串化
- <!DOCTYPE html>
- <html>
- <body>
- <h1>JSON.stringify 会把任何日期对象转换为字符串</h1>
- <p id="demo"></p>
- <script>
- var obj = { name: "Bill Gates", today: new Date(), city: "Seattle" };
- var myJSON = JSON.stringify(obj);
- document.getElementById("demo").innerHTML = myJSON;
- </script>
- </body>
- </html>