This will give you the current date in alert box.
JavaScript
<script type="text/javascript">
window.onload = function () {
var date = new Date();
alert(date.toDateString());
}
</script>
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
window.onload = function () {
var date = new Date();
alert(date.toDateString());
document.getElementById("date").innerHTML = date.toDateString();
}
</script>
</head>
<body>
Todays date is <span id="date"></span>
</body>
</html>
Demo