-6

I have a js time in milliseconds. How can I convert it to the format:

Day Mon date yyyy UTC GMT e.g Fri Feb 05 2016 00:00:00 GMT+0000 (GMT Standard Time)

Thanks

helpdesk
  • 1,984
  • 6
  • 32
  • 50
  • We wont help you with code right of the bat. But after one google search i found an answer on SO. http://stackoverflow.com/questions/4673527/converting-milliseconds-to-a-date-jquery-js – Johan Brännmar Feb 05 '16 at 09:46

2 Answers2

1

Just use this, where timestamp is yours

new Date(timestamp).toString()
Rene Pot
  • 24,681
  • 7
  • 68
  • 92
1
var milliseconds = new Date().getTime(); //Get milliseconds
var date = new Date(milliseconds); // Create date from milliseconds
console.log(date.toString()); //Log: Fri Feb 05 2016 12:41:18 GMT+0200 (EET)

// Let's create futureDate, 5days after now ...
var millisecondsInDay = 8.64e+7; // Milliseconds per day
var futureDate = new Date(milliseconds + 5*millisecondsInDay);
console.log(futureDate.toString()); //Log: Wed Feb 10 2016 12:41:18 GMT+0200 (EET)
Andriy Ivaneyko
  • 20,639
  • 6
  • 60
  • 82