JavaScript Status Text Clock

E-mail Print PDF

JavaScript Status Text Clock

Here we are going to display Text Clock at status bar of browser. If you are interested in details then please go through JavaScript Status clock – Basic and JavaScript Status clock – Advance.

First of all we have define variable var currentDate=new Date() and create a date object. Then define function NumToText() which take input as number which is output of method supported by date object.

hour = NumToText(currentDate.getHours())
min = NumToText(currentDate.getMinutes())
sec = NumToText(currentDate.getSeconds())

It process and depending on input parameter it return output as text. And we will get output as shown in figure below…

JavaScript Status Text Clock

Go through complete code to get detail how code works…

<script type="text/javascript">

function time(){
var TimeStamp,hour,period,min,sec;
var currentDate=new Date()

function NumToText(timestamp){
var y;
switch(timestamp){
case 0:y="Zero";break;
case 1:y="One";break;
case 2:y="Two";break;
case 3:y="Three";break;
case 4:y="Four";break;
case 5:y="Five";break;
case 6:y="Six";break;
case 7:y="Seven";break;
case 8:y="Eight";break;
case 9:y="Nine";break;
case 10:y="Ten";break;
case 11:y="Eleven";break;
case 12:y="Twelve";break;
case 13:y="Thirteen";break;
case 14:y="Fourteen";break;
case 15:y="Fifteen";break;
case 16:y="Sixteen";break;
case 17:y="Seventeen";break;
case 18:y="Eighteen";break;
case 19:y="Nineteen";break;
case 20:y="Twenty";break;
case 21:y="TwentyOne";break;
case 22:y="TwentyTwo";break;
case 23:y="TwentyThree";break;
case 24:y="TwentyFour";break;
case 25:y="TwentyFive";break;
case 26:y="TwentySix";break;
case 27:y="TwentySeven";break;
case 28:y="TwentyEight";break;
case 29:y="TwentyNine";break;
case 30:y="Thirty";break;
case 31:y="ThirtyOne";break;
case 32:y="ThirtyTwo";break;
case 33:y="ThirtyThree";break;
case 34:y="ThirtyFour";break;
case 35:y="ThirtyFive";break;
case 36:y="ThirtySix";break;
case 37:y="ThirtySeven";break;
case 38:y="ThirtyEight";break;
case 39:y="ThirtyNine";break;
case 40:y="Fourty";break;
case 41:y="FourtyOne";break;
case 42:y="FourtyTwo";break;
case 43:y="FourtyThree";break;
case 44:y="FourtyFour";break;
case 45:y="FourtyFive";break;
case 46:y="Fourtyix";break;
case 47:y="FourtySeven";break;
case 48:y="FourtyEight";break;
case 49:y="FourtyNine";break;
case 50:y="Fifty";break;
case 51:y="FiftyOne";break;
case 52:y="FiftyTwo";break;
case 53:y="FiftyThree";break;
case 54:y="FiftyFour";break;
case 55:y="FiftyFive";break;
case 56:y="FiftySix";break;
case 57:y="FiftySeven";break;
case 58:y="FiftyEight";break;
case 59:y="FiftyNine";break;
}
return y;
}
hour =NumToText(currentDate.getHours())
min = NumToText(currentDate.getMinutes())
sec = NumToText(currentDate.getSeconds())

if (hour>12){hour-=12;period="PM"} else {period="AM"}
if (currentDate.getHours()==12){period="PM"}
if (currentDate.getHours()==24){period="AM"}

var TimeStamp=hour+" O\'clock : "+min+" Minute: "+sec+" Second "+period
window.status=TimeStamp
window.setTimeout("time()",300)
}
time()
</script>

Example:

Please download source code to see example...

Source Code:

Download Source code for ‘JavaScript Status Text Clock’

Download

Also See:

Trackback(0)
Comments (1)Add Comment
...
written by Navin sharma, September 27, 2009
nice
'n' finally very nice

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

busy
Last Updated ( Thursday, 28 February 2008 15:44 )  

Who's Online

We have 19 guests online

Subscribe Feeds

Enter your email address:

Sponsor Adds



Submit Article

We want to develop such a Community portal which will provide a good resource on latest hot technologies such as .NET, VB.NET, C#.NET, ADO.NET, ASP.NET, PHP, Flash, Photoshop. If you like to write for us, this guideline for you. please send your article, faqs on admin[at]xfunda.com

Adobe Gallery Photoshop Tutorials...

Navi Avatar Photo Manipulation with Photoshop Navi Avatar Photo Manipulation with Photoshop Navi Avatar Photo Manipulation with Photoshop Categoty - Photoshop >> Photo Effects. ...
 
Gunshot Through a Glass Photoshop Tutorial Gunshot Through a Glass Photoshop Tutorial Gunshot Through a Glass Photoshop Tutorial Categoty - Photoshop >> Photo Effects. ...
 
How to Create an Abstract Image in Photoshop How to Create an Abstract Image in Photoshop How to Create an Abstract Image in Photoshop Categoty - Photoshop >> illustration and Art. ...
 
How to Create a Clean 3D Notepad in Photoshop How to Create a Clean 3D Notepad in Photoshop How to Create a Clean 3D Notepad in Photoshop Categoty - Photoshop >> illustration and Art. ...
 
Create an Amazing website Layout Using Textures Create an Amazing website Layout Using Textures Create an Amazing website Layout Using Textures Categoty - Photoshop >> Website Designing. ...