<script type= "Text/javascript" > var day1 = parseint (new Date (). valueof ()/1000); var day2 = new Date (day1 * 1000); function Getlocaltime (NS) { return new Date (parseint (NS) * 1000). toLocaleString (). Replace (/:d {1,2}$/, "); } /* with the above function * * function Getlocaltimes (NS) { return new Date (parseint (NS) * 1000). toLocaleString (). substr (0,17); } function Getlocalformattime (NS) { return new Date (parseint (NS) * 1000). toLocaleString (). Replace (/year | month/g, "-"). Replace (/day/g, ""); }
document.getElementById ("Btn1"). onclick = function () { alert (day1); } document.getElementById ("Btn2"). onclick = function () { Alert (day2.tolocalestring ()); } document.getElementById ("Btn3"). onclick = function () { Alert (Getlocaltime (day1)); } document.getElementById ("Btn4"). onclick = function () { Alert (Getlocalformattime (day1)); } document.getElementById ("Btn5"). onclick = function () { alert (day2.getfullyear () + "-" + (Day2.getmonth () + 1) + "-" +day2.getdate () + "" +day2.gethours () + ":" +day2.getminutes () + ":" +day2.getseconds ()); } </script> |