format a date in JavaScript?

To format a date use the following code – 

<script type=”text/javascript”>
var options = { weekday: ‘long’, year: ‘numeric’, month: ‘long’, day: ‘numeric’ };
var today = new Date();

console.log(today.toLocaleDateString(“en-US”)); // 9/17/2016
console.log(today.toLocaleDateString(“en-US”, options)); // Saturday, September 17, 2016
console.log(today.toLocaleDateString(“hi-IN”, options)); // शनिवार, 17 सितंबर 2016

</script>