Thursday, July 23, 2020

new Date() issue in Javascript, Get UTC date in Javascript

<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<p id="demo1"></p>
<script>
  var d = new Date("2020-07-01");
  document.getElementById("demo").innerHTML = d + ' ' + d.getTimezoneOffset();;
  d= new Date(d.getTime() + d.getTimezoneOffset() * 60000)
  document.getElementById("demo1").innerHTML =  d
</script>
</body>
</html>

No comments:

Post a Comment