0

I am storing Unix Timestamp in Firebase server and it is saving as 1417780144675.

When I am converting epochconverter the output is:

Assuming that this timestamp is in milliseconds:
GMT: Fri, 05 Dec 2014 11:49:04 GMT
Your time zone: 12/5/2014, 5:19:04 PM GMT+5:30

But when I am converting in JavaScript, the output is:

Fri Aug 30 46897 15:27:55 GMT+0530 (IST)

So output from epochconverter is correct whereas in JavaScript it's coming wrong.

Please how to get correct output using JavaScript.

5
  • 1
    Show us your JavaScript code please. We cannot say what you're doing wrong without seeing what you're doing. Commented Dec 5, 2014 at 13:42
  • Keep in mind that this type of question has been covered extensively here on StackOverflow. E.g. stackoverflow.com/questions/23483787/… Commented Dec 5, 2014 at 13:45
  • 2
    My guess is that you're looking for: new Date(1417780144675).toUTCString(), which returns "Fri, 05 Dec 2014 11:49:04 GMT" (like the middle line of epochconverter). Commented Dec 5, 2014 at 13:48
  • @FrankvanPuffelen, Thank you i have did in my code var datetime = new Date(data.created_at * 1000); Now its working fine with var datetime = new Date(data.created_at); Commented Dec 6, 2014 at 4:56
  • Good to hear that you got it working. Next time be sure to include such a code snippet in your question, without it we're playing a guessing game. Commented Dec 6, 2014 at 13:30

1 Answer 1

3

You should instanciate a new Date:

var date = new Date(1417780144675);

Output:

Fri Dec 05 2014 12:49:04 GMT+0100 
Sign up to request clarification or add additional context in comments.

1 Comment

Okay thank you i did like this var datetime = new Date(data.created_at * 1000); multiplied with 1000. Now it's working fine...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.