Convert UTC Time to Local Time

  1. <!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN"      
  2. "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">  
  3. <html  
  4.     xmlns="http://www.w3.org/1999/xhtml">  
  5.     <head>  
  6.         <title>Get local time</title>  
  7.         <script src="//code.jquery.com/jquery-1.10.2.js" language="javascript" type="text/javascript"></script>  
  8.         <script language="JavaScript" type="text/JavaScript"> function gettime() { var d = new Date(); document.getElementById("utctime").value= d; utc = d.getTime() + (d.getTimezoneOffset() * 60000); nd = new Date(utc + (3600000*+5.5)); var ist = nd.toLocaleString(); document.getElementById("localtime").value=ist; } </script>  
  9.     </head>  
  10.     <body onload="gettime()"> UTC time :  
  11.         <input type="text" id="utctime" />  
  12.         <br/>  
  13.         <br/> Local time :  
  14.         <input type="text" id="localtime" />  
  15.     </body>  
  16. </html>  
  17. <!DOCTYPE html PUBLIC "-//W3C//Dtd XHTML 1.0 Transitional//EN"         
  18.         
  19. "http://www.w3.org/tr/xhtml1/Dtd/xhtml1-transitional.dtd">  
  20. <html  
  21.     xmlns="http://www.w3.org/1999/xhtml">  
  22.     <head>  
  23.         <title>Get local time</title>  
  24.         <script src="//code.jquery.com/jquery-1.10.2.js" language="javascript" type="text/javascript"></script>  
  25.         <script language="JavaScript" type="text/JavaScript"> function gettime() { var d = new Date(); document.getElementById("utctime").value= d; utc = d.getTime() + (d.getTimezoneOffset() * 60000); nd = new Date(utc + (3600000*+5.5)); var ist = nd.toLocaleString(); document.getElementById("localtime").value=ist; } </script>  
  26.     </head>  
  27.     <body onload="gettime()"> UTC time :  
  28.         <input type="text" id="utctime" />  
  29.         <br/>  
  30.         <br/> Local time :  
  31.         <input type="text" id="localtime" />  
  32.     </body>  
  33. </html>