-1

How can i convert the javascript date to Json date format,

let see the same example here

my json date format = 1388923658000

Javascript date format =Sun Jan 05 2014 15:07:38 GMT+0300 (Arab Standard Time)

Now my question is, if i pass the current date means i need to return in json date format..

can you help me to solve this issue

Salman A
  • 262,204
  • 82
  • 430
  • 521
Prasad Raja
  • 685
  • 1
  • 9
  • 37

1 Answers1

1

Your JSON date looks like the number of milliseconds since 1 January 1970 00:00:00 UTC. The Date constructor happily accepts this:

var d = new Date(1388923658000);
console.log(d); // Sun Jan 05 2014 17:07:38 GMT+0500

If want it the other way round you need to:

var d = new Date();
console.log(d.getTime()); // 1391578510977
Salman A
  • 262,204
  • 82
  • 430
  • 521