Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.

JavaScript: Date Function

<html>
<head>
<title>Date Function</title>
<script language="javascript">
var cdate=new Date();
function day()
{
var d1=cdate.getDay();
if(d1==0)
d1="Sunday";
else if(d1==1)
d1="Monday";
else if(d1==2)
d1="Tuesday";
else if(d1==3)
d1="Wednesday";
else if(d1==4)
d1="Thursday";
else if(d1==5)
d1="Friday";
else if(d1==6)
d1="Saturday";
time.d.value=d1;
}
function month()
{
time.m.value=cdate.getMonth()+1;
}
function year()
{
var cyear=cdate.getYear();
time.y.value=cyear;
}
function hour()
{
time.h.value=cdate.getHours();
}
function minute()
{
time.m1.value=cdate.getMinutes();
}
function sec()
{
time.s1.value=cdate.getSeconds();
}
function time1()
{
time.t.value=cdate.getTime();
}
function date()
{
time.d1.value=cdate;
}
</script>
</head>
<body>
<form name="time">
<input type="button" value="Day" onclick="day()">
<input type="text" name="d">
<input type="button" value="Month" onclick="month()">
<input type="text" name="m">
<input type="button" value="Year" onclick="year()">
<input type="text" name="y">
<input type="button" value="Hour" onclick="hour()">
<input type="text" name="h">
<input type="button" value="Minute" onclick="minute()">
<input type="text" name="m1">
<input type="button" value="Second" onclick="sec()">
<input type="text" name="s1">
<input type="button" value="Time" onclick="time1()">
<input type="text" name="t">
<input type="button" value="Date" onclick="date()">
<input type="text" name="d1">
</form>
</body>
</html>

No comments:

Post a Comment

Google