• Image 1
  • Image 2
  • Image 3
  • Image 4
  • Image 5
  • Image 6
  • Image 7




Wednesday, July 11, 2012

TUTORIAL JAVASCRIPT - DATE AND TIME FOR NEWBIE


Hello…. You now in my page… in We Are Knowledge….
Let’s read , my article..


A. Method Date and Time

In javascript we can too made date and time. For made date and time we must declarasion variable or object date or time it.

Sintaks:
Var mydate = new Date()

In this table to be found more method date and time for javascript

Method
Define
getDay()
For to appear date in a month
getDay()
To result name of day
getHours()
To result hour (start = 0, end = 23)
getMinutes()
To result minutes (start = 1 end = 60)
getSecond()
To result second (start = 1 end = 60)
getMonth
To result name of moon (start = 1 end = 12)
getYear()
To result year
getTime()
To result time more full

Example:

<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
</head>
<body>
<script type = "text/javascript">
var
a = new Date()
b = a.getYear()
c = a.getMonth()
d = a.getDate()
document.write("Date for today: ")
document.write(d +"-"+c+"-"+ b)
</script>
</body>
</html>

To result :
Date for today : 07-06-2012


B. Javascript Timer

In javascript to be found too function “timer”, is seTimeout(), this avail to manage or setting timer for working a function or other code.

Sintaks:
setTimeout(“expression”, delaytime)

Expression can javascript code or a function
Define delay is every how millisecond a expression want execution

example:

<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
</head>
<body>
<input type = "text" id="timer" name="text">
<input type = "button" name="knop" value="ClicK" onClick="count()">
<script type = "text/javascript">
var
c = 0
document.getElementById("timer").value= ""
function count()
{
document.getElementById("timer").value=c
c=c+1
setTimeout("count()", 1000)
}
</script>
</body>
</html>


C. Digital Clock

You can copy and paste thiscode in your application..

<html>
<head>We Are Knowledge<br>
<title>Tutorial Javascript - Array</title>
</head>
<body>
<form name="timer">
<input type ="text" size = "12" name="clock">
</form>
<script type = "text/javascript">
function show()
{
var
a = new Date()
b = a.getHours()
c = a.getMinutes()
d = a.getSeconds()
e = "AM"
if(b > 12)
{
e = "PM"
b = b - 12
}
if (b == 0)
b = 12
if (c <= 9)
c = "0" + c
if (d <= 9)
d = "0" + d
document.timer.clock.value = b + ":" + c + ":" + d + " " + e
seTimeout ("show()", 1000)
}
show()
</script>
</body>
</html>


Ok… just it thanks for you was reading my article . Don’t forget for reading my other article…

Ok.. see you again… in my other page

No comments:

Post a Comment