动态显示当前时间(js)
来源:互联网 发布:淘宝店名能改几次 编辑:程序博客网 时间:2024/05/19 02:41
方法一:
现在时刻: <span id="t01"></span>
<script type="text/javascript">
function gettime()
{
document.getElementById('t01').innerHTML=new Date().toLocaleString();
}
setInterval(gettime,1000);
</script>
方法二:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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 runat="server">
<title>无标题页</title>
<script language="JavaScript" type="text/javascript">
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock () {
stopclock();
showtime();
}
function showtime () {
var now = new Date();
var date=now.toLocaleDateString();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
//var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )
//timeValue += ((hours >12) ? hours -12 :hours)
var timeValue =date+" "+hours;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes ;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds ;
document.getElementById("txtTime").value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
</script>
</head>
<body onload="startclock()">
<form id="form1" runat="server">
<div>
<span style="font-size:14px"> 当前时间:</span>
<input name="txtTime" style="font-size: 9pt;color:#000000;border:0; width: 145px; height: 19px;" id="txtTime" readonly="readOnly" />
</div>
</form>
</body>
</html>
预览效果:
- 动态显示当前时间(js)
- js动态显示当前时间
- JS显示动态显示当前时间代码
- js显示当前时间(动态)以及限时抢购倒计时
- JS动态显示当前系统时间
- js动态显示系统当前时间
- PHP+JS动态显示当前时间
- 动态显示当前时间
- js显示当前时间
- js 显示当前时间
- js 显示当前时间
- js显示当前时间
- JS显示当前时间
- js动态显示当前日期,时间和星期代码
- js动态显示当前日期,时间和星期代码
- js动态显示当前日期,时间和星期代码
- jsp页面利用js动态显示当前系统时间
- 网页动态显示当前时间
- SqlDataReader的GetChar不支持所指定的方法
- java读取zip文件和压缩zip文件
- C++ string转换CString .
- Apache与Tomcat的区别以及几种常见的web应用服务器
- http://www.jeasyui.com/demo/index.php
- 动态显示当前时间(js)
- Session是通过Cookie来传id的
- memcpy memmove区别和实现
- HDU 1568 Fibonacci
- flash开发中提高性能方法的整理(分享)
- Lua for循环
- 使用Loadrunner进行文件的上传和下载
- poj 2528 线段树 lazy Mayor's poster
- leeboy的linux学习五