【第六篇】javascript显示当前的时间(年月日 时分秒 星期)
不多说自己上代码
这是我开始学javascript写的,现在发出来
<span id="clock" ></span>
function time() {
var today = new Date();
var hou;
var time;
var day;
if (today.getHours() < 12 && today.getHours() >= 0) {
hou = today.getHours();
time = "AM";
} else if (today.getHours() <= 24 && today.getHours() > 12) {
hou = today.getHours() - 12;
time = "PM";
}
var d = today.getDay();
if (d == 0) {
day = "日";
} else if (d == 1) {
day = "一";
} else if (d == 2) {
day = "二";
} else if (d == 3) {
day = "三";
} else if (d == 4) {
day = "四";
} else if (d == 5) {
day = "五";
} else if (d == 6) {
day = "六";
}
document.getElementById("clock").innerHTML = (today.getFullYear() + "年" + (today.getMonth() + 1) + "月" + today.getDate() + "日 " + hou + ":" + today.getMinutes() + ":" + today.getSeconds() + " " + time + " 星期" + day);
}
var myTime = setInterval("time()", 1000);
效果图

---------------------------------------------------------------------------------------------------------
转载请记得说明作者和出处哦-.-
作者:KingDuDu
原文出处:https://www.cnblogs.com/kingdudu/articles/4745675.html
---------------------------------------------------------------------------------------------------------
【第六篇】javascript显示当前的时间(年月日 时分秒 星期)的更多相关文章
- Swift3.0 iOS获取当前时间 - 年月日时分秒星期
Swift3.0 iOS获取当前时间 - 年月日时分秒星期func getTimes() -> [Int] { var timers: [Int] = [] // 返回的数组 let calen ...
- java 获得当前时间 年月日时分秒 星期几
<%SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");//设置日期格式SimpleDat ...
- js如何获得系统时间年月日时分秒
javascript 自带有个对象(构造函数),Date().下面是代码: 回答一: var now = new Date(); var nowTime = now.toLocaleString() ...
- sqlserver 获取时间年月日时分秒
转自:http://blog.itpub.net/14766526/viewspace-1156100/ select GETDATE() as '当前日期',DateName(year,GetDat ...
- C#:获取时间年月日时分秒格式
//获取日期+时间 DateTime.Now.ToString(); // 2008-9-4 20:02:10 DateTime.Now.ToLocalTime().ToStri ...
- mssql 格式化字符串 /时间 年月日时分秒
比如:1 想格式化 000001,100 格式化为000100: 思路是这样的 1000000 +格式化的数字 取后6位: select right(cast(power(10,6) as var ...
- JavaScript中的内置对象-8--4.date对象中-获取,设置日期时间的方法; 获取,设置年月日时分秒及星期的方法;
学习目标 1.掌握创建日期对象的方法 2.掌握date对象中获取日期时间的方法 3.掌握date对象中设置日期时间的方法 如何创建一个日期对象 语法:new Date(); 功能:创建一个日期时间对象 ...
- 时间操作(JavaScript版)—页面显示格式:年月日 上午下午 时分秒 星期
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/wangshuxuncom/article/details/35222531 <!DOCTYPE ...
- 在vue项目中显示实时时间(年月日时分秒)
1.在data中定义一个变量,存储时间 data(){ return { nowTime:'' } }, 2.给定一个div <div>{{nowTime}}</div> 3. ...
随机推荐
- Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 8
Refer :http://www.cnblogs.com/mengfanrong/p/3745475.html Righ click on your project > properties ...
- 13test05:亲密数
/*#include<iostream> using namespace std; int main() {int sum[3000]={0}; for(int i=1;i<3000 ...
- MySQL中文全文索引插件 mysqlcft 1.0.0 安装使用文档[原创]
[文章+程序 作者:张宴 本文版本:v1.0 最后修改:2008.07.01 转载请注明原文链接:http://blog.zyan.cc/post/356/] MySQL在高并发连接.数据库记录数较多 ...
- 由浅入深了解Thrift之客户端连接池化
一.问题描述 在上一篇<由浅入深了解Thrift之服务模型和序列化机制>文章中,我们已经了解了thrift的基本架构和网络服务模型的优缺点.如今的互联网圈中,RPC服务化的思想如火如荼.我 ...
- 3[doses] ------一种诡异的写法
在 head first c 的第60页,有这么一道题: 一个富翁因为服药过度而死亡. 下面是自动服药器的代码: #include <stdio.h> int main(void) { , ...
- POJ1474 Video Surveillance(半平面交)
求多边形核的存在性,过了这题但是过不了另一题的,不知道是模板的问题还是什么,但是这个模板还是可以过绝大部分的题的... #pragma warning(disable:4996) #include & ...
- PHP一些函数
函数不定参数: func_num_args // 获得参数个数 func_get_args // 获得参数数组 call_user_func('function_name', $parameter) ...
- Java框架----SSH整合回顾
1,新建工程,类型为Web Project,设置默认编码为UTF-8,并创建如下文件夹 1,Source Folder 1,src 项目源码 2,config 配置文件 3,test 单元测试 2,普 ...
- lintcode:将二叉查找树转换成双链表
题目 将一个二叉查找树按照中序遍历转换成双向链表 给定一个二叉查找树: 4 / \ 2 5 / \ 1 3 返回 1<->2<->3<->4<->5. ...
- lintcode: 最长无重复字符的子串
题目 最长无重复字符的子串给定一个字符串,请找出其中无重复字符的最长子字符串. 例如,在"abcabcbb"中,其无重复字符的最长子字符串是"abc",其长度为 ...