Javascript Data Type How to - Change Date format








Question

We would like to know how to change Date format.

Answer


<!--  ww  w .ja  v  a 2 s .  com-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/1.7.2/moment.min.js"></script>
<script type='text/javascript'>

var inDate = '08/11/2012';
var outDate = moment(inDate, "DD/MM/YYYY").format('DD-MMM-YYYY').toUpperCase();
document.write(outDate);

</script>
</head>
<body>
</body>
</html>

The code above is rendered as follows: