js 时间
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript">
window.onload=function(){
setInterval(a
,1000);
a();
function a(){
var body=document.body;
var myTime = new Date();
var iYear = myTime.getFullYear();
var iMonth = myTime.getMonth()+1;
var iDate = myTime.getDate();
var iWeek = myTime.getDay();if(iWeek==0){
iWeek="星期天";if( iWeek === 0 ) iWeek = '星期日';
if( iWeek === 1 ) iWeek = '星期一';
if( iWeek === 2 ) iWeek = '星期二';
if( iWeek === 3 ) iWeek = '星期三';
if( iWeek === 4 ) iWeek = '星期四';
if( iWeek === 5 ) iWeek = '星期五';
if( iWeek === 6 ) iWeek = '星期六';
}
var iHours = myTime.getHours();
var iMin = myTime.getMinutes();
var iSec = myTime.getSeconds();
var str=iYear+ '年' +iMonth+'月'+iDate+'日 '+ b(iWeek)+' '+ b(iHours)+' : '+ b(iMin)+' : '+ b(iSec);
body.innerHTML=str;
}
function b(n){
if(n<10){
return "0"+n;
}
else{
return ""+ n;
}
}
js 时间的更多相关文章
- js 时间构造函数
js 时间构造函数,js中没有类似ToString("yyyy-mm-dd HH:mm:ss") 的方法,但是可以用下面的方式来初始化 var cdate = new Date(& ...
- js时间倒计时
看了网上的其他的例子,觉得写的都有点复杂,不好理解,于是自己动手写了个. 本来想封装成jquery插件,但是觉得因为功能很简单,没有必要做成jquery插件,引用的时候不需要引入jqery库,这里直接 ...
- js 时间处理
1.格式化时间 function GetDateTimeFormatter(value) { if (value == undefined) { return &q ...
- Js 时间与字符串转示例
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- js获取当前时间,js时间函数
Js获取当前日期时间及其它操作,js时间函数 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); ...
- js 时间函数 及相关运算大全
js 时间函数 及相关运算大全 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); ...
- js时间过滤方法
js时间过滤 自己写的 记录一下 /** * * 过滤时间格式 * Created by Catlina at 2019.4.26 */ export const setTime = time = ...
- js 时间类函数
js 时间类是 Date() var currtime = new Date();// 实例一个时间,是当前时间 接收一个时间戳为参数 var time2=new Date(currtime.get ...
- js 时间格式化 (兼容safari)
js 时间格式化,兼容IE8和safari浏览器. function formatDate(date, fmt, near, type) { var dateStr = date; if (!date ...
- js时间格式化函数,支持Unix时间戳
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
随机推荐
- 网站引导页flash动画跳转js脚本
if (getCookie("guidance") == null) { document.cookie = "guidance=true"; window.l ...
- Maven中央(或国内)仓库地址
maven官方 http://repo1.maven.org/maven2/ 或 http://repo2.maven.org/maven2/ (延迟低一些) osc 本家 http://maven ...
- ubuntu jdk环境变量配置
export JAVA_HOME=/usr/local/java/jdk1.8.0_25 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:$ ...
- php系统无法上传图片问题
PHP Warning: File upload error - unable to create a temporary file in Unknown on line 0 我的测试环境是 w ...
- JavaScript 属性操作
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- Eight
Eight 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1043/http://acm.split.hdu.edu.cn/showproblem.ph ...
- ios根据文本自适应 然后 搭建类似如下效果
UIView * headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.tbSecond.size.width, 0)]; hea ...
- 关于autoconf
1 the difference between AC_ARG_ENABLE and AC_ARG_WITH AC_ARG_ENABLE是enable一个feature,该feature所对应的源码包 ...
- js-json教程从入门到使用
json教程从入门到使用 2.json例子: var today_data={"city":"上海","area":"6400&q ...
- bzoj2052: Pku1777 Vivian
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=2052 2052: Pku1777 Vivian Time Limit: 10 Sec M ...