Cheps
Cheps

Reputation: 515

convert timestamp Date to javaScript date

in fact, I called my java services from AngularJS and I go back an object that contains a date, for example:

{
"Name": "Jhon"
"date": 1465826400000
}

in my service java 1465826400000 date corresponds to Monday, June 13, 2016 14: 00 UTC and in my Javascript code:

var date = new Date (1465826400000);

and it gives 14-06-2016 4:00:00

that means one day lag between the two dates.

someone has an idea

Upvotes: 1

Views: 5684

Answers (1)

T.J. Crowder
T.J. Crowder

Reputation: 1075885

No, it just means you're looking at the result in the local timezone of your browser. If you look at it as a UTC date, it matches:

console.log(new Date (1465826400000).toISOString()); // "2016-06-13T14:00:00.000Z"

Upvotes: 4

Related Questions