Jump to content

I cant find the difference


Leon

Recommended Posts

1)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
</head>
<body>
<p>Current Time</p>
<p id="CurrentTime"></p>
<script>
var myVaribale=setInterval(thetimeisnow,1000);
function thetimeisnow(){
var y=new Date();
document.getElementById("CurrentTime").innerHTML=y;
}
</script>
</body>
</html>

 

 

 

 

 

2)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 2</title>
</head>
<body>
<p>Current Time</p>
<p id="CurrentTime"></p>
<script>
var myVaribale=setInterval(thetimeisnow,1000);
function thetimeisnow(){
var y=new Date();
document.getElementById("CurrentTime").innerHTML=y.toLocaleDateString();
}
</script>
</body>
</html>

 

 

 

"The first code, i can display time and date but idk how to change the time zone. The second one if i include "toLocaleDateString();"it will be display only date not the time.. if without"toLocaleDateString();" it will display the output on the first image can someone tell me why? "

post-190011-0-94476600-1445483464_thumb.png

post-190011-0-74105500-1445484106_thumb.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...