Home
Developer Blog
Ajax effects
CSS examples
Freelance jobs
Hot IT Jobs
Hot scripts
Code samples
Web hosting directory
Lotus Notes FAQ
See the new scripts recently added to Dynamic Drive.
Click here
.
Original, practical
CSS codes and examples
such as CSS menus for your site.
Search code samples
Keyword
All Categories
ASP
CSS
Dhtml
Html
Javascript
PHP
Code Samples
ASP
CSS
Dhtml
Html
Javascript
PHP
LOGIN HERE
Username
Password
Signup Now
Forgot Password
Verify Signup
Javascript >> General
how to get current time using JavaScript?
Visitor Ratings (8) :
Description
The getDay() method returns a number that specifies the day of the week. Sunday is represented by 0, Monday by 1 and so on. Here again we employ an array. This array would contain the Day names.
Code
Select All
<SCRIPT LANGUAGE="JAVASCRIPT"> <!-- var d_names = new Array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var m_names = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); var d = new Date(); var curr_day = d.getDay(); var curr_date = d.getDate(); var sup = ""; if (curr_date == 1 || curr_date == 21 || curr_date ==31) { sup = "st"; } else if (curr_date == 2 || curr_date == 22) { sup = "nd"; } else if (curr_date == 3 || curr_date == 23) { sup = "rd"; } else { sup = "th"; } var curr_month = d.getMonth(); var curr_year = d.getFullYear(); document.write(d_names[curr_day] + " " + curr_date + "<SUP>" + sup + "</SUP> " + m_names[curr_month] + " " + curr_year); //--> </SCRIPT>
Rate this Resource
0
1
2
3
4
5
6
7
8
9
10