CHAPTER - 17

Date and Time


The Date object has been created, and now we have a variable that holds the current date! To get the information we need to print out, we have to utilize some or all of the following functions:

getTime() - Number of milliseconds since 1/1/1970 @ 12:00 AM

getSeconds() - Number of seconds (0-59)

getMinutes() - Number of minutes (0-59)

getHours() - Number of hours (0-23)

getDay() - Day of the week(0-6). 0 = Sunday, ... , 6 = Saturday

getDate() - Day of the month (0-31)

getMonth() - Number of month (0-11)

getFullYear() - The four digit year (1970-9999)

<h4>It is now
<script type="text/javascript">

<!--

var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
document.write(hours + ":" + minutes + " ")
if(hours > 11){
document.write("PM")
}else{
document.write("AM")
}

//-->

</script>
</h4>

Comments

Popular posts from this blog

INTRODUCTION CHAPTER - 1

CHAPTER - 5