Monday, 21 April 2014

Show Date Time by JScript

If you want to show Date & Time in your  Web Page
Add the javascript:
<script>
<!--
 
    function show() {
        var Digital = new Date()
        var hours = Digital.getHours()
        var minutes = Digital.getMinutes()
        var seconds = Digital.getSeconds()
        var dn = "AM"
              
        var dd = Digital.getDate()
        var mm = Digital.getMonth()+1
        var yyyy=Digital.getFullYear()

        if (dd <= 9)
            dd = "0" + dd
        if (mm <= 9)
            mm = "0" + mm
        var date =  dd+ " - " + mm + "- " + yyyy        
        if (hours > 12) {
            dn = "PM"
            hours = hours - 12
        }
        if (hours <= 9)
            hours = "0" + hours
        if (hours == 0)
            hours = 12
        if (minutes <= 9)
            minutes = "0" + minutes
        if (seconds <= 9)
            seconds = "0" + seconds
        document.getElementById('Clock').innerHTML = date +" , " +   hours + ":" + minutes + ":"
        + seconds + " " + dn      
        setTimeout("show()", 1000)
    }
    show()
    //-->
</script>

No comments:

Post a Comment