-2

I send to JS a json datetime object, how i can convert it to datetime JS object?

PHP return:

"date": {
  "lastErrors": {
     "warning_count":0,
     "warnings":[],
     "error_count":0,
     "errors":[]
  },
  "timezone": {
    "name":"Europe\/Warsaw",
    "location": {
      "country_code":"PL",
      "latitude":52.25,
      "longitude":21,
      "comments":""
    }
  },
  "offset":7200,
  "timestamp":1399413600
}

I need in JavaScript Hours and minutes to easy summarize and display.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
user3468055
  • 263
  • 1
  • 5
  • 16

1 Answers1

1

Going from JSON to Datetime object using unix timestamp

s = '{"date":{"lastErrors":{"warning_count":0,"warnings":[],"error_count":0,"errors":[]},"timezone":{"name":"Europe\/Warsaw","location":{"country_code":"PL","latitude":52.25,"longitude":21,"comments":""}},"offset":7200,"timestamp":1399413600}}'
new Date(JSON.parse(s).date.timestamp * 1000)
Fabricator
  • 12,722
  • 2
  • 27
  • 40