0

I am trying to populate a datetime field on an edit form with a date that is coming from the server in UTC. The problem is when I do

var dat = new Date("UTC date");
dateField.value = dat.toISOString();

it is in UTC and not in the local timezone the user is in.

How to go about setting the value to datetime field which is according to his timezone and not UTC?

Rajat Saxena
  • 3,834
  • 5
  • 45
  • 63
  • This might help you: http://stackoverflow.com/questions/6525538/convert-utc-date-time-to-local-date-time-using-javascript – Pit Feb 16 '16 at 10:24

1 Answers1

0

try using

   var date = new Date('2012-12-12 15:00:00 UTC');
   console.log(date.toString());
Pandiyan Cool
  • 6,381
  • 8
  • 51
  • 87