0

I want to get the date without GMT but i get it wrong when i affect in the object. there is an example :

var object = {
    startTime: "",
    endTime: "",
   }


  startTime = new Date();
  endTime = new Date();

  var startDateMinute = startTime.getMinutes();

  startTime.setMinutes(startDateMinute + 1);
  endTime.setMinutes(startDateMinute + 2);

  console.log("- startTime  = "+startTime , 1);
  console.log("- endTime  = "+endTime , 1);

  object.endTime = new Date(startTime).toISOString();
  object.startTime = new Date(startTime);

  console.log("- object :  = "+JSON.stringify(object));

the result of this example is :

- startTime  = Mon Aug 29 2016 11:30:01 GMT+0200 (CEST)
- endTime  = Mon Aug 29 2016 11:31:01 GMT+0200 (CEST)
- object :  = {"startTime":"2016-08-29T09:30:01.905Z","endTime":"2016-08-29T09:30:01.905Z"}

why the time in the object is wrong ? I want to have the right time with gmt add in the time like this :
- object : = {"startTime":"2016-08-29T11:30:01.905Z","endTime":"2016-08-29T11:30:01.905Z"}

collo21
  • 105
  • 1
  • 10

1 Answers1

2

Use The MomentJS Library For all date related things.

http://momentjs.com/

Shankar Shastri
  • 1,134
  • 11
  • 18