Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



Create A Clock With Javascript

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 20-01-2010
Member
 
Join Date: Nov 2009
Posts: 877
Create A Clock With Javascript
  

Hello, I am learning java script by own. And I want to create a script which can provide me clock. If anybody knows code for this script then please provide me that. If you know the sources then also provide me. Suggest me some good books for basic javascrpt understanding.

Reply With Quote
  #2  
Old 20-01-2010
Member
 
Join Date: May 2008
Posts: 2,007
Re: Create A Clock With Javascript

I think you may need to use javascript books below to get this solution :
  • JavaScript Programmer's Reference
  • Beginning JavaScript
  • javascript: The Definitive Guide
  • Instant JavaScript
  • JavaScript Application Cookbook
  • Learn Advanced JavaScript Programming
Reply With Quote
  #3  
Old 20-01-2010
Member
 
Join Date: Apr 2008
Posts: 2,000
Re: Create A Clock With Javascript

The script below will provide you A clock in javascript:
Code:
<html>
<head>
<script type="text/javascript">
function time()
{
var now=new Date();
var hr=now.getHours();
var minute=now.getMinutes();
var s=now.getSeconds();
minute=checkTime(minute);
seconds=checkTime(seconds);
document.getElementById('txt').innerHTML=h+":"+minute+":"+seconds;
t=setTimeout('time()',500);
}

function checkTime(i)
{
if (i<10)
  {
  i="0" + i;
  }
return i;
}
</script>
</head>

<body onload="time()">
<div id="txt"></div>
</body>
</html>
Reply With Quote
  #4  
Old 20-01-2010
Member
 
Join Date: May 2008
Posts: 2,290
Re: Create A Clock With Javascript

I have created the script below for getting clock in javascript. You canmake use of it.
Code:
<script type="text/javascript">
<!--
function updateClock ( )
{
  var currt = new Date ( );
  var currh = currt.getHours ( );
  var currm= currt.getMinutes ( );
  var currs = currt.getSeconds ( );
  currm= ( currm< 10 ? "0" : "" ) + currm;
  currs = ( currs < 10 ? "0" : "" ) + currs;
  var timeOfDay = ( currh < 12 ) ? "AM" : "PM";
  currh = ( currh > 12 ) ? currh - 12 : currh;
  currh = ( currh == 0 ) ? 12 : currh;
  var currtString = currh + ":" + currm+ ":" + currs + " " + timeOfDay;
  document.getElementById("clock").firstChild.nodeValue = currtString;
}
// -->
</script>
Reply With Quote
  #5  
Old 20-01-2010
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Create A Clock With Javascript

Use the methods below to create your Javascript for getting the clock:
  1. getDate() - For returning day of month
  2. getDay() - For returning day of week
  3. getHours() - For returning hour
  4. getMinutes() - For returning minutes
  5. getSeconds() - For returning seconds
  6. getMonth() - For returning month
  7. getYear() - For returning year
  8. getTime() - For returning complete time
Reply With Quote
  #6  
Old 20-01-2010
Member
 
Join Date: Feb 2008
Posts: 1,845
Re: Create A Clock With Javascript

You need to make use of the list below for javascript reference:
  • JavaScript Programmer's Reference
  • Teach Yourself JavaScript In A Week
  • Using JavaScript Special Edition
  • JavaScript For The World Wide Web 2
  • Instant JavaScript
I always use JavaScript Programmer's Reference for my reference.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Create A Clock With Javascript"
Thread Thread Starter Forum Replies Last Post
How to use javascript to create HTML and CSS KennedII Software Development 5 22-02-2010 11:10 PM
Create calculator with the use of JavaScript Jagdish Gada Software Development 3 14-11-2009 09:00 AM
JavaScript - How to create Element Xylina Software Development 3 04-06-2009 05:06 PM
How to create analog clock using Small Basic EricTheRed Guides & Tutorials 3 21-04-2009 06:34 PM
Create php alert pop ups using javascript. Suzane Software Development 3 13-04-2009 03:39 PM


All times are GMT +5.5. The time now is 10:24 PM.