当前时间 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 ...
随机推荐
- Learning WCF Chapter1 Creating a New Service from Scratch
You’re about to be introduced to the WCF service. This lab isn’t your typical “Hello World”—it’s “He ...
- bzoj3172
这里学习AC自动机其实对KMP和trie掌握好了之后很容易扩展成AC自动机的这里运用了一个性质由失配指针反向可以建成一棵fail树x串在y串中的出现的次数即为在fail树上以x结尾节点为根的子树中有多 ...
- js 弹出页面传值
有页面a和页面b,页面a中有一个文本框和一个按钮,点按钮弹出页面b,页面b也有一个文本框,在文本框中输入值,在不经过后台用js实现把页面b的文本框的值传到页面a,赋给页面a的文本框 a页面代码< ...
- HDU 2546 饭卡
http://acm.hdu.edu.cn/showproblem.php?pid=2546 呆呆. 饭卡 Time Limit: 5000/1000 MS (Java/Others) Memo ...
- 去掉有序数组中重复数字 原地 leetcode java (最简单的方法)
1.利用荷兰国旗的思路,每次记住最后一个位置,遇到一个不重复的数,放在它后面,代码很简单. Given a sorted array, remove the duplicates in place s ...
- Hadoop--map/reduce实现单词计数
import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.*; import org.apache.hadoop.mapred.*; ...
- HW4.28
import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner i ...
- PHP向MySql中插入数据
<!DOCTYPE html> <!-- To change this license header, choose License Headers in Project Prope ...
- 手机APP上下滚动翻页效果
//页面初期加载时 $(document).ready(function () { //加载第一页 LoadList(); //滚动换页 $( ...
- OGG问题 ORA-01403的处理办法
认识logdump分析工具及常用命令:http://book.51cto.com/art/201202/319253.htm http://www.killdb.com/2012/09/01/gold ...