I am populating a Google sheet with data from a JSON object I receive from Postman. Some of the information I receive is in this format:
{"attempt_starttime": "2021-09-21T03:28:13+0000",
"attempt_endtime":"2021-09-21T03:28:35+0000",
"invited_on":"2021-09-21T03:27:50+0000"}
I need to do some manipulations on them. What I want to know is
Thank you!
Adapt as you need...
function chrono() {
var days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
var jsonString = `{"attempt_starttime": "2021-09-21T03:28:13+0000",
"attempt_endtime":"2021-09-21T03:28:35+0000",
"invited_on":"2021-09-21T03:27:50+0000"}`
var data = JSON.parse(jsonString)
var startTime = new Date(data.attempt_starttime)
var endTime = new Date(data.attempt_endtime)
var invitedTime = new Date(data.invited_on)
console.log(startTime + ' ... ' + days[startTime.getDay()])
console.log(endTime + ' ... ' + days[endTime.getDay()])
console.log(invitedTime + ' ... ' + days[invitedTime.getDay()])
console.log(invitedTime.getUTCHours());
console.log(invitedTime.getUTCMinutes());
console.log(invitedTime.getUTCSeconds());
console.log((startTime-invitedTime)/1000 + ' secondes')
console.log((endTime-startTime)/1000 + ' secondes')
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.