JS Date当前时间:获取日期时间方法在各浏览器中的差异
转自:http://www.feiesoft.com/00047/
<script type="text/javascript">
// JS Date当前时间获取方法在各浏览器中的差异
// 当前时间:
var dt = new Date();
// Date([datetime])构造函数初始化对象时不输入参数 [datetime] ,则以用户本地电脑上的时间初始化 dt。
// dt 是一个 JS Date对象,在字符串环境下输出当前时间标准格式串,即此时自动调用 dt 对象的toString()方法(注:在JS中,任何对象都有一个 toString()方法,用于输出一些关于对象直观上的文本表述。)。
// 例:
document.writeln(dt);
document.writeln(dt.toString());
// 各浏览器输出:
//
// 微软 IE10 浏览器: Sat Nov 2 03:48:58 UTC+0800 2013
// 谷歌 Chrome 浏览器:Sat Nov 02 2013 04:07:03 GMT+0800 (中国标准时间)
// 奇虎360安全浏览器:Sat Nov 02 2013 03:49:54 GMT+0800 (中国标准时间)
// Firefox 25.0 火狐浏览器:Sat Nov 02 2013 03:55:02 GMT+0800
//
//日期、时间
document.writeln(dt.toLocaleString());
//
// 微软 IE10 浏览器: 2013年11月2日 4:15:55
// 谷歌 Chrome 浏览器:2013年11月2日 上午4:15:43
// 奇虎360安全浏览器:Sat Nov 02 2013 04:16:41 GMT+0800 (中国标准时间)
// Firefox 25.0 火狐浏览器:2013年11月2日 4:18:30
//
//在地日期:
document.writeln(dt.toLocaleDateString());
//
// 微软 IE10 浏览器: 2013年11月2日
// 谷歌 Chrome 浏览器:2013年11月2日
// 奇虎360安全浏览器:Saturday, November 02, 2013
// Firefox 25.0 火狐浏览器:2013年11月2日
//
//在地时间:
document.writeln(dt.toLocaleTimeString());
//
// 微软 IE10 浏览器: 4:20:04
// 谷歌 Chrome 浏览器:上午4:20:06
// 奇虎360安全浏览器:04:20:08
// Firefox 25.0 火狐浏览器:04:20:08
//
// 如果要得到“YYYY年MM月DD日 HH:mm:SS”格式的当前时间值,强烈推荐用:
//
document.writeln(dt.getFullYear() + "年" + dt.getMonth() + "月" + dt.getDate() + "日 " + dt.getHours() + ":" + dt.getMinutes() + ":" + dt.getSeconds());
</script>
JS Date当前时间:获取日期时间方法在各浏览器中的差异的更多相关文章
- DateTime.ToString格式化日期,使用DateDiff方法获取日期时间的间隔数
一:DateTime.ToString格式化日期 二:代码 using System; using System.Collections.Generic; using System.Component ...
- 使用DateDiff方法获取日期时间的间隔数
一:用DateDiff方法获取日期时间的间隔数,截图 二:代码 using System; using System.Windows.Forms; using Microsoft.VisualBasi ...
- 一起Polyfill系列:让Date识别ISO 8601日期时间格式
一.什么是ISO 8601日期时间格式 ISO 8601是国际标准化组织制定的日期时间表示规范,全称是<数据存储和交换形式·信息交换·日期和时间的表示方法>. 示例: 1. 2014-12 ...
- PHP获取日期时间信息
getdate函数 描述:可以获取日期/时间信息 语法:array getdate( [ int timestamp ] ) 返回一个数组 例: Array ( [seconds] => 30 ...
- SQL日期操作及只获取日期的方法
datepart()函数的使用 * datepart()函数可以方便的取到时期中的各个部分*如日期:2006-07--02 18:15:36.513* ...
- PHPCMS V9调用时间标签 |日期时间格式化
PHPCMS V9 如何调用时间标签,下面分享常见的调用时间标签 |日期时间格式化 1.日期时间格式化显示: a标准型:{date('Y-m-d H:i:s', $rs['inputtime'])} ...
- 【转】Python3 日期时间 相关模块(time(时间) / datatime(日期时间) / calendar(日历))
Python3 日期时间 相关模块(time(时间) / datatime(日期时间) / calendar(日历)) 本文由 Luzhuo 编写,转发请保留该信息. 原文: http://blog. ...
- Python3 日期时间 相关模块(time(时间) / datatime(日期时间) / calendar(日历))
Python3 日期时间 相关模块(time(时间) / datatime(日期时间) / calendar(日历)) 本文由 Luzhuo 编写,转发请保留该信息. 原文: http://blog. ...
- js new Date("2016-07-01 08:00:00") 格式在IE内核浏览器中显示NaN的问题
js new Date("2016-07-01 08:00:00") 格式在IE内核浏览器中显示NaN的问题 废话就不多了,var dd = new Date("2016 ...
随机推荐
- poj3662 最短路+二分
//Accepted 508 KB 79 ms //spfa+二分 //二分需要的花费cost,把图中大于cost的边设为1,小于cost的边设为0,然后spfa求 //最短路,如果小于K则可行,继续 ...
- 在linux使用make编译ArduPilot for Pixhawk/PX4 ArduPilot 编译环境搭建
Building ArduPilot for Pixhawk/PX4 on Linux with Make 使用Make编译 ArduPilot for Pixhawk 2, Pixhawk and ...
- 北大poj- 1067
取石子游戏 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 40058 Accepted: 13520 Descripti ...
- JSP 甜点
JSP cookies Cookies是存储在客户机的文本文件,它们保存了大量轨迹信息.在servlet技术基础上,JSP显然能够提供对HTTP cookies的支持. 通常有三个步骤来识别回头客: ...
- net iis 部署中出现的问题及解决方案
1.HTTP500.21 错误 解决方法:重新注册asp.net C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe –i ...
- Xen启动过程分析(还是分享过来吧,找了好长时间)
XEN启动过程 Xen Hypervisor运行在Ring0,在启动过程中,Xen首先被引导:系统由Grub启动,遵循Multiboot引导规范:然后Linux内核做为module也被引导入 ...
- void 关键字
1. void 的字面意思为“无类型”,void*为“无类型指针”,void*可以指向任何类型的数据 2 用于数据类型封装,典型的如内存操作函数 memcpy 和 memset 的函数原型分别为: v ...
- SELECT控件操作的JS代码示例
SELECT控件操作的JS代码示例 1 检测是否有选中 if(objSelect.selectedIndex > -1) { //说明选中 } else { //说明没有选中 } 2.动态创建s ...
- 佛祖保佑,永无bug
/* _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : | ...
- Robot_bfs
Description The Robot Moving Institute is using a robot in their local store to transport different ...