home

Javascript Date Time Tutorial


Date & Time

<script type="text/javascript">
var currentdate = new Date()
document.write(currentdate)
document.write("<BR>")


var currentmonth = currentdate.getMonth()+1
document.write("Current months is ")
document.write(currentmonth)
document.write("<BR>")


var currenthours = currentdate.getHours()
document.write("Current hour ")
document.write(currenthours)
document.write("<BR>")

var timeofday = (currenthours < 12) ? "AM" : "PM"
currenthours = (currenthours > 12) ? currenthours - 12 : currenthours
currenthours = (currenthours == 0) ? 12 : currenthours
document.write(currenthours)


//getMonth, getHours, getSeconds, getDay, getMinutes


</script>

 

 

 

 


Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Copyright © 2014 by Cramerz.com.