Javascript Data Type How to - Convert yyyy-mm-dd as '2011-12-30' to UTC








Question

We would like to know how to convert yyyy-mm-dd as '2011-12-30' to UTC.

Answer


<!DOCTYPE html>
<html>
<body>
<script type='text/javascript'>
document.body.innerHTML = new Date('2011-12-30').toUTCString();
</script>
</body>
</html>

The code above is rendered as follows: