JavaScript基础17——js的Date对象
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>js的Date对象</title>
<script type="text/javascript">
var date = new Date();
document.write("当前日期:" + date);
// toLocaleString()方法,根据本地时间格式,把Date对象转换为字符串
document.write("<br />格式化 toLocaleString()方法:" + date.toLocaleString());
// getFullYear()方法,得到当前的四位数年份
document.write("<br />年份 getFullYear():" + date.getFullYear());
// getMonth()方法,得到当前的月份(0-11)
document.write("<br />月份 getMonth():" + (date.getMonth() + 1));
// getDay()方法,得到当前的星期(0-6),外国朋友把星期日作为一周的第一天,所以星期日返回0
document.write("<br />星期 getDay():" + date.getDay());
// getDate()方法,得到当前的日(1-31)
document.write("<br />日 getDate():" + date.getDate());
// getHours()方法,得到当前的小时(0-23)
document.write("<br />小时 getHours():" + date.getHours());
// getMinutes()方法,得到当前的分钟(0-59)
document.write("<br />分钟 getMinutes():" + date.getMinutes());
// getSeconds()方法,得到当前的秒钟(0-59)
document.write("<br />秒钟 getSeconds():" + date.getSeconds());
// getMilliseconds()方法,得到当前的毫秒(0-999)
document.write("<br />毫秒 getMilliseconds():" + date.getMilliseconds());
// getTime()方法,获取1970年1月1日至今的毫秒数
/*
使用毫秒数处理缓存的效果(没有缓存)
http://www.baidu.com?getTime()的值
*/
document.write("<br />1970年1月1日至今的毫秒数 getTime():" + date.getTime());
</script>
</head>
<body> </body>
</html>

JavaScript基础17——js的Date对象的更多相关文章
- JavaScript基础15——js的DOM对象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JavaScript基础18——js的Array对象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JavaScript基础16——js的BOM对象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JavaScript基础14——js的Math对象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JavaScript基础13——js的string对象
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- JavaScript基础-05-数组、Date对象、Math、包装类、字符串方法
数组(Array) 1. 数组 数组也是一个对象,不同点:普通对象是使用字符串作为属性名的,数组是使用数字作为索引操作元素. 数组的存储性能比普通对象要好,在开发中经常使用数组来存储一些数据. 向数组 ...
- 【JavaScript基础】Js的定时器(你想看的原理也在哟)
[JavaScript基础]Js的定时器(你想看的原理也在哟) 博客说明 文章所涉及的资料来自互联网整理和个人总结,意在于个人学习和经验汇总,如有什么地方侵权,请联系本人删除,谢谢! 说明 本章是经历 ...
- js实现小时钟,js中Date对象的使用?
介绍一下js中Date对象的使用 dateObj = new Date() dateObj = new Date(dateValue) dateObj = new Date(year,month,da ...
- JavaScript学习12 JS中定义对象的几种方式
JavaScript学习12 JS中定义对象的几种方式 JavaScript中没有类的概念,只有对象. 在JavaScript中定义对象可以采用以下几种方式: 1.基于已有对象扩充其属性和方法 2.工 ...
随机推荐
- 将数据转化成字符串时:用字符串的链接 还是 StringBuilder
/* 目的:将数据转化成字符串时:用字符串的链接 还是 StringBuilder呢? */ public class Test{ public static void main(String[] a ...
- php易混淆知识点
一.define(“constant”, “hello world”);和const constant = “hello world”;的区别? (0).使用const使得代码简单易读,const本 ...
- Tools - 国内开源镜像网站
阿里云镜像 网易开源镜像站 搜狐开源镜像站 香港中文大学 清华大学开源软件镜像站 中国科学技术大学开源软件镜像 中国互联网络信息中心开源镜像站 - apache开源软件镜像
- 【Swift学习】Swift编程之旅---闭包(十一)
闭包是可以在代码中被传递和使用的自包含功能模块,它很像c和oc中的block,和.net中的lambdasbas表达式. 闭包可以捕获和存储其所在上下文中任意常量和变量的引用. 包裹着这些常量和变量的 ...
- 【转载】各浏览器CSS兼容问题
CSS对浏览器的兼容性有时让人很头疼,或许当你了解当中的技巧跟原理,就会觉得也不是难事,从网上收集了IE7,6与Fireofx的兼容性处理方法并 整理了一下.对于web2.0的过度,请尽量用xhtml ...
- iOS的QuickTime Plugin
当UIWebView播放视频时,可以看到view hierarchy里有FigPluginView的身影.这个类来自于QuickTime Plugin,plugin的路径为: /Application ...
- MySQL Information Functions
Table 12.18 Information Functions Name Description BENCHMARK() Repeatedly execute an expression CHAR ...
- form表单
<form> <input type="text" value="123"> 文本输入框,value值为显示在文本框中的默认值, ...
- 2016暑假多校联合---Substring(后缀数组)
2016暑假多校联合---Substring Problem Description ?? is practicing his program skill, and now he is given a ...
- MAC下反編譯安卓APK
所需工具: 1.apktool http://ibotpeaches.github.io/Apktool/ (配置說明) https://bitbucket.org/iBotPeac ...