JavaScript Date Format dd/mm/yyyy

JavaScript String Date format dd/mm/yyyy hh:m:s  using a 24 hour clock:

<script>

function formatDate() {
var d = new Date();
var dd = d.getDate();
var mm = Number(d.getMonth() + 1);
var yyyy = d.getFullYear();

if (mm.toString().length == 1)
mm = “0” + mm;

var hh = d.getHours();
var m = d.getMinutes();
var s = d.getSeconds();

if (hh.toString().length == 1)
hh = “0” + hh;

return mm + “/” + dd + “/” + yyyy + ” ” + hh + “:” + m + “:” + s;
}

</script>

for meridian timing / 12 hour clocks ……

Continue reading