Can Chrome not handle Date syntax?

In my last post I have shown that how to get day date and Year through Javascript. Well this was fine till I used that code in IE. But that code failed while opened in Chrome browser.

<TITLE> Date validations </TITLE>
                var monthNames = new Array(12);
                monthNames[0]= "January";
                monthNames[1]= "February";
                monthNames[2]= "March";
                monthNames[3]= "April";
                monthNames[4]= "May";
                monthNames[5]= "June";
                monthNames[6]= "July";
                monthNames[7]= "August";
                monthNames[8]= "September";
                monthNames[9]= "October";
                monthNames[10]= "November";
                monthNames[11]= "December";

                var dayNames = new Array(7);
                dayNames[0]= "Sunday";
                dayNames[1]= "Monday";
                dayNames[2]= "Tuesday";
                dayNames[3]= "Wednesday";
                dayNames[4]= "Thursday";
                dayNames[5]= "Friday";
                dayNames[6]= "Saturday";

                function customDateString (my_date)
                                var daywords = dayNames[my_date.getDay()];
                                var theday = my_date.getDate();
                                var themonth = monthNames[my_date.getMonth()];
                                var theyear = my_date.getYear();
                                return daywords + ",  " + themonth + " " + theday + ", " + theyear;

                document.write(customDateString( new Date()))
To my surprise IE is showing correct date day and year but Chrome has failed to show the same...

Not very sure what went wrong.
Let me know if you have the answare.

Can Chrome not handle Date syntax? Can Chrome not handle Date syntax? Reviewed by Animesh Chatterjee on February 23, 2012 Rating: 5

No comments:

Powered by Blogger.