-3

I am using angular-moment-picker to pick time ( hours and minutes ). I got the time in this format HH:mm as it is shown in my source code below:

<div class="form-group">
     <p class="icon-group input-group ">
      <input readonly ng-model="workTime.startTime" class="form-control">
      <span class="input-group-btn ">
       <button moment-picker="startTime" format="HH:mm" type="button" class="btn btn-default" id="startTime">
        <i aria-hidden="true" class="glyphicon glyphicon-calendar"></i>
       </button>
      </span>
      <span class="show-date-picker"></span>
     </p>
   </div>

After that i formatted it in date format like that:

var startDate=new Date();
var start=$scope.startTime.toString().trim().split(':');
startDate.setHours(start[0]);
startDate.setMinutes(start[1]);
startDate.setSeconds(0);

I got the date in this format:

Mon, 05 Jun 2017 12:00:00 GMT

whenever I store this date in oracle database I got Mon, 05 Jun 2017 11:00:00 GMT

Can someone explain to me why the time is reduced by one hour.

Thank you

Rodrigo
  • 327
  • 6
  • 25
  • 1
    and why down vote, can you expain ?? – Rodrigo Jun 05 '17 at 16:18
  • 1
    I didn't down vote you, but I'm willing to bet it's because the question in itself shows you have made no effort to research things yourself. Any simple search for keywords such as `javascript date convert gmt` would have given you a handful of answers. – ippi Jun 05 '17 at 16:27
  • @ippi thank for answering, Yeah maybe if it seems to the voter but me I already tested, and I already saw this issue but doesn't help me to solve my issue. Regards – Rodrigo Jun 05 '17 at 16:27
  • @ippi thanks, Javascript date convert gmt already looked for, I found toGMTString() ad doesn't work for me. Regards – Rodrigo Jun 05 '17 at 16:29
  • @ippi can you reread my issue i have updated it – Rodrigo Jun 05 '17 at 20:58

1 Answers1

2

You can display your date on UTC like this:

const date = new Date();
console.log(date.toUTCString());
Blackus
  • 6,883
  • 5
  • 40
  • 51