Javascript: Current Date
            

ncthakur.itgo.com   Javascript: Current Date

         NEPAL     |     ARTICLES     |     KAVITAHARU    |     MANTHAN    |     COOL LINKS    |     GUESTBOOK    |     SEARCH

JAVASCRIPT
As I have learned as a beginner:
1. Opening New Window

2. Use of Alert, Prompt & Confirm

3. Document Write

4. Use of Function

5. Event Handlers (Image Rollover)

6. If and Else Statement

7. Predefined Object (Date)

8. Cut & Paste JavaScript

NEPAL
Overview of Nepal
Map & images
Nepalese websites

KAVITAHARU
View few of my poems
written in Nepali language

ARTICLES
Articles on
crime prevention
investigation
& crime control

COOL LINKS
Computer
Travel & Tour
Police World
Downloads
Personality Test
Nepal News
Crime & Police News
Nepali Music
Health
Horoscope
Monthly Poll
Other

ADD EMAIL
Search or add email to the search list.

GUESTBOOK
View to find out what other visitors have to say about this web site.

KURAKANI
Are you interested to chat? Go to Kurakani room.

FREE E-CARDS
Enormous free E-Cards of your choice. Send it to your friend and family members.

FREE SITE SUBMIT
Submit your web site to the major search engines here.

ABOUT ME
Click here to find out about me and view few of my photographs.

 

Pre-defined Object (Date)

DATE:a predefined object:
getYear(): returns year
getmonth(): returns month(start from 0)
getDate(); returns day of the month
getDay(): returns day of the week
getHours(): returns hour(starts from 0)
getMinutes(): returns minutes
getseconds(): returns seconds
getTime(): returns complete time

Example of getting current date
<script language="JavaScript">
<!-- Hide from older browser
document.write("Today's date is:"+Date())
//-->
</script>
The above code will give you current date and time in its predifined style. Click on EXAMPLE to view.


But if you want the current date and time in your own style here is the example.
<script language="JavaScript">
<!-- Hide from older browser
var x= new Date()
var y= x.getYear()
var m= x.getMonth()+1  // added +1 because javascript counts month from 0
var d= x.getDate()
var h= x.getHours()
var mi= x.getMinutes()
var s= x.getSeconds()
document.write("Today's date is: ")
document.write(m+'/'+d+'/'+y+'  '+h+'.'+mi+'.'+s)
//-->
</script>




This is the example of a CLOCK

<TABLE BORDER=1 BGCOLOR=LIGHTGREEN>
<TH>JavaScript's CLOCK </TH><TR><TD>
<FORM NAME="NCT3">
<INPUT TYPE=TEXT NAME="time" SIZE=25 >
</FORM>
<SCRIPT LANGUAGE="JavaScript">
<!-- Hide from older browser
function myClock(){
myTime = new Date();
document.NCT3.time.value = " "+myTime;
document.NCT3.time.blur();
setTimeout("myClock()", 1000);
}
myClock();
//-->
</SCRIPT>
</TD></TR>
</TABLE>


JavaScript's CLOCK


For Ready Made JavaScripts

Cut & Paste JavaScript

BACK


Top

Home  | About Me  |  Nepal  |  Articles  | Kavitaharu  | Cool Links 
 Javascript  | Add Email  |  Guestbook