Leon Posted October 22, 2015 Share Posted October 22, 2015 1) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <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"> <html xmlns="http://www.w3.org/1999/xhtml"> <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? " Link to comment Share on other sites More sharing options...
davej Posted October 22, 2015 Share Posted October 22, 2015 The browser uses whatever time zone the computer OS is set to. There are a variety of Date related methods... http://www.w3schools.com/jsref/jsref_obj_date.asp Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now