Monday, 22 May 2017

Why Date object one day behind only on the server side but not on the localhost in javascript?

The following code appends 00 hrs, mts and sec on the date

let setStartSTime = new Date(my_date);
setStartSTime = setStartSTime.getFullYear() + "-"
              + (setStartSTime.getMonth()+1) + "-"
              + setStartSTime.getDate()+" "
              + 00 + ":"+ 00 + ":"+ 00;
    console.log(setStartSTime + 'setStartSTime');

||ly, The following code appends 23 hrs, 59 mts and 59 sec on the date

let endStartSTime = new Date(my_date);
    endStartSTime = endStartSTime.getFullYear() + "-"
                  + (endStartSTime.getMonth()+1) + "-"
                  + endStartSTime.getDate()+" "
                  + 23 + ":"+ 59 + ":"+ 59;

The server hosted in US Amazon Server. That's why Date object takes one day behind the date that I have passing

If I pass 25th, then it will take 24, for 24, it is 23rd and son

How can I override this thing ? I am using nodejs for server side I hope I am able to explain it.



via VIKAS KOHLI

No comments:

Post a Comment