Forum : jsbasics
Brief description  about Online courses   join in Online courses
View nishant  gaurav 's Profile

jsbasics

help me out in dispalying the date
my coding is not working at all.
<html>
<head>
<script type="text/javascript">
function showdate()
{
var now=new Date();
var hours=now.getHour();
var minutes=now.getMinutes();
var seconds=now.getSeconds();
var thetime=hours ":" minutes ":" seconds;
return now;
return thetime;
}

</script>
</head>
<body>
<script type="text/javascript"><form>
<input type="Button" value="date is" onclick="showdate()"/></form>
</script>
</body>
</html>
Asked by nishant gaurav | Aug 29, 2010 |  Reply now
Replies (5)
View nishant gaurav 's Profile
thanks sir
Aug 31, 2010
View anonymous anonymouse 's Profile
<html>
<head>
<script type="text/javascript">
function showtime()
{
var now=new Date();
var hours=now.getHours();
var minutes=now.getMinutes();
var seconds=now.getSeconds();

/*var day=" ";
if(hours>=12)

day="P.M";
else
day="A.M";
document.myform.dateis.value=hours+": "+minutes+": "+seconds+" "+day;
setTimeout('showdate()', 1000);
//return now;
//return thetime;*/
document.write(hours+": "+minutes+": "+seconds);
}

</script>
</head>
<body>
<form name="myform">
<input type="button" value="Show Time" " onclick="showtime();"/></form>
</script>
</body>
</html>
Aug 29, 2010
View anonymous anonymouse 's Profile
For every Second the clock gets triggered.

that's after 1000 milliseconds the clock gets triggered.
Aug 29, 2010
View anonymous anonymouse 's Profile
<html>
<head>
<script type="text/javascript">
function showtime()
{
var now=new Date();
var hours=now.getHours();
var minutes=now.getMinutes();
var seconds=now.getSeconds();

var day=" ";
if(hours>=12)

day="P.M";
else
day="A.M";
document.myform.timeis.value=hours+": "+minutes+": "+seconds+" "+day;
setTimeout('showtime()', 1000);
//return now;
//return thetime;
}

</script>
</head>
<body>
<form name="myform">
Time: <input type="text" name="timeis" " /></form>
<script type="text/javascript">
showtime();
</script>
</body>
</html>
Aug 29, 2010
View anonymous anonymouse 's Profile
<script type="text/javascript"><form>
<input type="Button" value="date is" onclick="showdate()"/></form>
</script>
Don't use input element inside Script tag ,use it with form tag as shown.


var hours=now.getHour(); is var hours=now.getHours();

Aug 29, 2010