-2

i want get current time, when i convert new Date() into sting but when it converts reduces 5.30 hours based on my time zone.

enter image description here

How can i get same time which returns in new Date() method?

kumaresan_sd
  • 941
  • 1
  • 8
  • 24
  • 1
    Does this answer your question? [Create a Date with a set timezone without using a string representation](https://stackoverflow.com/questions/439630/create-a-date-with-a-set-timezone-without-using-a-string-representation) – AZ_ Dec 21 '20 at 07:46

1 Answers1

0

Try this

var today = new Date();
var date = today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate();
var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
var dateTime = date+' '+time;

How ever format you want you may adjust

Shantun Parmar
  • 394
  • 1
  • 10