function getServerTime() { if (num < 60) { num += 1; sec++; if (sec == 60) { min += 1; sec = 0; } if (min == 60) { hour += 1; min = 0; } if (hour == 24) { date += 1; hour = 0; } if (month == 1 || month == 3 || month == 5 || month == 7 || month == 9 || month == 12) { if (date == 32) { date = 1; month += 1; } } else if (month == 4 || month == 6 || month == 9 || month == 11) { if (date == 31) { date = 1; month += 1; } } else if (month == 2) { //闰年处理 if (year%4==0&&year%100!=0) { { if (date == 29) { date = 1; month += 1; } } } else { if (date == 28) { date = 1; month += 1; } } } if (month == 13) { year += 1; month = 1; } } else { num = 0; Refresh(); } var ssec = addZero(sec); var smin = addZero(min); var shour = addZero(hour); var sdate = addZero(date); var smonth = addZero(month); var syear = year; $("#timebox").text(syear + "-" + smonth + "-" + sdate + "-" + shour + "-" + smin + "-" + ssec); window.setTimeout("getServerTime()", 1000); }
相关阅读 >>
asp.net中关于webapi与ajax进行跨域数据交互时cookies数据的传递
详解asp.net使用ajax实现分页局部刷新页面功能的代码实例
更多相关阅读请进入《时间》频道 >>

C#高级编程(第11版) C# 7 & .NET Core 2.0(.NET开发经典名著)
作者:[美]克里斯琴·内格尔(Christian Nagel)著。出版时间:2019年3月。