I am new Ionic and I am not able to access a single value from json object. I want to console log the value of timestamp which I get from API.
My TS code is something like this
viewTime(){
let url = 'http://api.timezonedb.com/v2.1/get-time-zone?key=8304HG08VTGQ&format=json&by=zone&zone=Asia/Kolkata';
this.http.request(url, this.config.options)
.subscribe((response: any) => {
console.log(response);
this.data = response ;
console.log(this.data.timestamp); // i want this value to console log
let date = new Date()
var myDate = new Date(new Date().getTime()+(7*24*60*60*1000));
console.log(myDate);
console.log("Current Date ",date);
this.nav.setRoot(AccountLogin);
}, (err) => {
let alert = this.alertCtrl.create({
title: 'Error',
subTitle: 'Please check your zone',
buttons: ['OK']
});
alert.present();
});
}
My API looks like this:
{
"status": "OK",
"message": "",
"countryCode": "IN",
"countryName": "India",
"zoneName": "Asia/Kolkata",
"abbreviation": "IST",
"gmtOffset": 19800,
"dst": "0",
"zoneStart": -764145000,
"zoneEnd": 0,
"nextAbbreviation": "",
"timestamp": 1538838621,
"formatted": "2018-10-06 15:10:21"
}
How to access timestamp value in console log?