"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Friday, August 5, 2011

Show Date in webpage using javascript

Hi *.*,
This is my third post regarding show date on webpage. Fortunately all are unique :).



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>

    <script type="text/javascript">
        function showdate() {
            var mydate = new Date()
            var year = mydate.getYear()
            if (year < 1000)
                year += 1900
            var day = mydate.getDay()
            var month = mydate.getMonth()
            var daym = mydate.getDate()
            if (daym < 10)
                daym = "0" + daym
            var dayarray = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday")
            var montharray = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
            document.write("<p class=normal><font size='1' color='black' face='Arial'> &nbsp;" + dayarray[day] + ", " + montharray[month] + " " + daym + ", " + year + "</font></b></p>")
        }
    </script>

</head>
<body onload="showdate();">
    <form id="form1" runat="server">
    <div>
    </div>
    </form>
</body>
</html>



Its simple one, U can read this as a poem in-case any trouble remember my name, Happy to help u with a smile.


Stay Tune...
Have a nice day... 'N happy Coding :)

No comments: