JS Get current time
//gets the current time, format Yyyy-mm-dd functiongetnowformatdate () {varDate =NewDate (); varSeperator1 = "-"; varYear =date.getfullyear (); varmonth = Date.getmonth () + 1; varStrdate =date.getdate (); if(Month >= 1 && month <= 9) {Month= "0" +month; } if(strdate >= 0 && strdate <= 9) {strdate= "0" +strdate; } varcurrentdate = year + seperator1 + month + Seperator1 +strdate; returncurrentdate; }
JS page Add clock
<script type= "Text/javascript" >functionrealsystime (clock) {varnow =NewDate (); varYear =now.getfullyear (); varmonth =Now.getmonth (); varDate =now.getdate (); varDay =Now.getday (); varhour =now.gethours (); varMinu =now.getminutes (); varSEC =now.getseconds (); Month= Month+1; varArr_week =NewArray ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); varWeek =Arr_week[day]; varTime = year+ "year" +month+ "month" +date+ "Day" + "+week+" "+hour+": "+minu+": "+sec; Clock.innerhtml=Time ;} Window.onload=function() {Window.setinterval ("Realsystime (Clock)", 1000);}</script>
<div id= "Clock" ></div>
JS get current time &js page clock