Json Date format

2019-09-25 06:26发布

Can you any one explain this date format . this is my table id=8 data I am not understand this format

  id=8|startTime=1900-02-20 00:00:00|endTime=1900-02-20 00:00:00                        
 |AverageMeetTime=60|idDoctor=3|cancelled=0|permanentlyCancelled=0 

   JSON FORMAT SHOW THIS::

 {
 "averageMeetTime": 60,

 "cancelled": false,

 "endTime": 
 {
 "date": 20,

 "day": 5,

"hours": 0,

"minutes": 0,

"month": 1,

"seconds": 0,

"time": 1424370600000,

"timezoneOffset": -330,

"year": 115

 },

"id": 8,

"idDoctor": 3,

"permanentlyCancelled": false,

"startTime": 
 {
"date": 20,

"day": 5,

"hours": 0,

"minutes": 0,

"month": 1,

"seconds": 0,

"time": 1424370600000,

"timezoneOffset": -330,

"year": 115

}

}

can you explain this date format .......

+------------+---------------------+---------------------+-----------------+-----------------+------------------------+-------------+
| idTimeSlot | startTime           | endTime             | averageMeetTime | Doctor_idDoctor | isPermanentlyCancelled | isCancelled |
+------------+---------------------+---------------------+-----------------+-----------------+------------------------+-------------+
|          1 | 2016-02-20 01:00:00 | 2016-02-20 02:00:00 | 20              |               3 |                      0 |           0 |
|          2 | 2016-02-21 01:00:00 | 2016-02-21 02:00:00 | 60              |               3 |                      0 |           0 |
|          3 | 2016-02-22 01:00:00 | 2016-02-22 02:00:00 | 60              |               3 |                      0 |           0 |
|          4 | 2016-02-23 01:00:00 | 2016-02-23 02:00:00 | 60              |               3 |                      0 |           0 |
|          5 | 2016-02-24 01:00:00 | 2016-02-24 02:00:00 | 60              |               3 |                      0 |           0 |
|          6 | 2016-02-25 01:00:00 | 2016-02-25 02:00:00 | 60              |               3 |                      0 |           0 |
|          7 | 2016-02-26 01:00:00 | 2016-02-26 02:00:00 | 60              |               3 |                      0 |           0 |
|          8 | 1900-02-20 00:00:00 | 1900-02-20 00:00:00 | 60              |               3 |                      0 |           0 |
+------------+---------------------+---------------------+-----------------+-----------------+------------------------+-------------+

1条回答
放我归山
2楼-- · 2019-09-25 07:01

You need to store JSON object to a variable to use its properties to create Date object, because this JSON object is not of Date type. You can use any constructor from the JavaScript Dates.

And I want this format only .....(yyyy-MM-dd)

You can use time property.

var json = {"endTime": {
               "date": 20,
               "day": 5,
               "hours": 0,
               "minutes": 0,
               "month": 1,
               "seconds": 0,
               "time": 1424370600000,
               "timezoneOffset": -330,
               "year": 115 
             }
           };


document.getElementById("demo").innerHTML = new Date(json.endTime.time).toLocaleFormat("%Y-%m-%d");

JSFiddle

查看更多
登录 后发表回答