/**
* @author Alfred
*/
<html>
<body>
<script type="text/javascript">
//create new date object
var someDate = new Date("31 Jan 2003 11:59");
//retrieve the first four values using the appropriat get methods
document.write("Minutes = " + someDate.getMinutes() + "
");
document.write("Year = " + someDate.getFullYear() + "
");
document.write("Month = " + someDate.getMonth() + "
");
document.write("Date = " + someDate.getDate() + "
");
// Set the minutes to 34
someDate.setMinutes( 34 );
document.write("Minutes = " + someDate.getMinutes() + "
");
// Reset the date
someDate.setDate(32);
document.write("Date = " + someDate.getDate() + "
");
document.write("Month = + someDate.getMonth() + "
");
</script>
</body>
</html>
Here is another tutorial on Rounding
<script type="text/javascript">
function roundNumber(num){
document.write("round() = " + Math.round(num));
document.write("<br>");
document.write("floor() = " + Math.floor(num));
document.write("<br>");
document.write("ceil() = " + Math.ceil(num));
document.write("<br>");
}
var numberToRound = prompt("Please enter a number", "");
roundNumber(numberToRound);
numberToRound = 49.293;
document.write("Number to round = " + numberToRound + "<BR>");
roundNumber(numberToRound);
numberToRound = 58.63;
document.write("Number to round = " + numberToRound + "<BR>");
roundNumber(numberToRound);
</script>
No comments:
Post a Comment