<!-- JavaScript:Dates code snippet 2. -->
<!-- Create a 'Date' object and write the adjusted values to the page
in a recognised format -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Code source: http://www.justfigures.co.uk/ -->
<!-- A resource for web developers using XHTML, CSS, JavaScript, PHP -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>View code snippet page</title>
<script language="JavaScript" type="text/javascript">
<!-- begin
function writeDateObject()
{
/* create a new date object called 'now' */
var now = new Date();
/* use the Date object methods to obtain the Date object values
and assign to variables */
/* add 1 to 'month' to adjust value */
var date = now.getDate();
var month = now.getMonth()+1;
var year = now.getFullYear();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
/* write out these values */
document.write("Date is: "+date+"/"+month+"/"+year+". Time is: "+hour+":"+minute+":"+second);
}
// end -->
</script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
<!--
writeDateObject();
// -->
</script>
</body>
</html>