Json Date Format

Can you explain this date format. this is my table id = 8 data I do 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

}

}

You can 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 |
+------------+---------------------+---------------------+-----------------+-----------------+------------------------+-------------+
-3
source share
1 answer

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

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

You can use the property time.

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

0
source

Source: https://habr.com/ru/post/1673971/


All Articles