当前时间 js
效果:

代码:
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>倒计时js代码</title>
<style>
*
{
margin: 0;
padding: 0;
list-style: none;
}
body
{
font-size: 18px;
text-align: center;
}
.time
{
height: 30px;
padding: 200px;
}
</style>
</head>
<body>
</div>
<!--当前时间-->
<div id="show">
</div>
</body> <script>//当前时间
window.onload = function() {
var show = document.getElementById("show");
setInterval(function() {
var time = new Date();
// 程序计时的月从0开始取值后+1
var m = time.getMonth() + 1;
var t = time.getFullYear() + "-" + m + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
show.innerHTML = t;
}, 1000);
};
</script> </html>
动态显示当前时间,带日期
效果:

代码:
//动态显示当前的时间
function GetTime(obj) {
var myDate = new Date();
var Today = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
//获取当前年
var Years = myDate.getFullYear();
//获取当前月
var Months = myDate.getMonth() + 1;
//获取当前日
var Dates = myDate.getDate(); //获取当前天是当前周的第几天
var Days = Today[myDate.getDay()]; //获取当前的时
var Hours = myDate.getHours();
//获取当前的分
var Minutes = myDate.getMinutes();
//获取当前的秒
var Seconds = myDate.getSeconds(); Months = Months < 10 ? "0" + Months : Months;
Dates = Dates < 10 ? "0" + Dates : Dates; Hours = Hours < 10 ? "0" + Hours : Hours;
Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
Seconds = Seconds < 10 ? "0" + Seconds : Seconds; return Years + "年" + Months + "月" + Dates + "日" + " " + Days + " " + Hours + ":" + Minutes + ":" + Seconds;
} function showTitleInfo() {
document.getElementById("dateInfo").innerHTML = GetTime();
setTimeout("showTitleInfo()", 1000);
}
showTitleInfo();
当前时间 js的更多相关文章
- js获取当前时间&js 页面时钟
js获取当前时间 //获取当前时间,格式YYYY-MM-DD function getNowFormatDate() { var date = new Date(); var seperator1 = ...
- js获取当前时间,js时间函数
Js获取当前日期时间及其它操作,js时间函数 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); ...
- 页面显示时间js
//页面显示时间 <span align="left" id="OperatorTime"> </span> <script> ...
- js格式化时间 js格式化时间戳
一个js格式化时间和js格式化时间戳的例子. 代码:/** * 时间对象的格式化; */Date.prototype.format = function(format) { /* * eg:forma ...
- 日期时间JS插件
首先要引入基本文件:bootstrap的基本js和css文件,因为用到了jquery所以要引入jquery文件 <script src="jquery-1.11.2.min.js&qu ...
- MVC中的时间js格式化
记录下我遇到的一个,MVC中post请求返回一个JSON字符串,其中包含数据库中的时间格式(如:/Date(10000000000)/),不知道怎么处理.百度的方法都不适用,经自己研究,做成了一个Jq ...
- js动态获取当前系统时间+js字符串转换为date日期对象
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 时间js
function DateUtil(){ this.url = ""; this.op={ partten:{mdy:"m/d/y",ymd:"y/m ...
- 时间js转换方法Date("149...") 转成 2016-7-12 21:23:34 009
function timeFormatter(value) { var da = new Date(parseInt(value.replace("/Date(", &q ...
随机推荐
- Android日期时间格式国际化
公共类 的DateFormatSymbols 扩展对象 实现 Serializable接口 Cloneable接口 java.lang.Object的 ↳ java.text.DateForma ...
- CF 370
A:http://codeforces.com/problemset/problem/370/A #include<stdio.h> #include<string.h> #i ...
- DBcontext应用于已存在数据库
转自:http://www.cnblogs.com/Tally/archive/2013/01/30/2882855.html EF4.1有三种方式来进行数据操作及持久化.分别是Database-Fi ...
- HDOJ --1172
#include<iostream> #include<cstdio> #include<cstring> #include<string> #incl ...
- container_of宏剖析
container_of宏剖析//该宏位于include/linux/kernel.h 1.定义格式 /** * container_of - cast a member of a structure ...
- HW4.13
public class Solution { public static void main(String[] args) { int n = 0; while(n * n * n < 120 ...
- Command-line interface
A command-line interface (CLI), also known as command-line user interface, console user interface, a ...
- 关于ASSERT(断言)的作用
程序一般分为Debug 版本和Release 版本,Debug 版本用于内部调试,Release 版本发行给用户使用.断言assert 是仅在Debug 版本起作用的宏,它用于检查“不应该”发生的情况 ...
- POJ 3922 A simple stone game
题目: E - A simple stone game Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d &am ...
- jQuery CSS 的操作函数
jQuery CSS 操作函数 下面列出的这些方法设置或返回元素的 CSS 相关属性. CSS 属性 描述 css() 设置或返回匹配元素的样式属性. height() 设置或返回匹配元素的高度. o ...