JavaScript Date
来源:互联网 发布:恶意百度点击软件 编辑:程序博客网 时间:2024/06/06 02:55
/*Date对象属性*/ /*construction属性返回创建对象的Date函数引用*/ var txt = new Date(); if(txt.constructor == Array){ document.write("<p>This is an Array"); } if(txt.constructor == Date){ document.write("<p>This is a Date"); } if(txt.constructor == String){ document.write("<p>This is a String"); } /*prototype属性能向对象添加属性和方法*/ function flower(name,color){ this.name = name ; this.color = color; } var rose = new flower("rose","red"); flower.prototype.price = null; rose.price ="$20"; document.write("<p>prototype()添加新的属性:"+rose.price+"</p>") console.log(rose); /*Date 对象属性*/ var d = new Date(); var birthday = new Date("May 30,1991"); //Date(month day,year time) var someday = new Date(); var weekday = new Array(7); weekday[0] = "Sunday" weekday[1] = "Monday" weekday[2] = "Tuesday" weekday[3] = "Wednesday" weekday[4] = "Thursday" weekday[5] = "Friday" weekday[6] = "Saturday" var month = new Array(12) month[0] = "January" month[1] = "February" month[2] = "March" month[3] = "April" month[4] = "May" month[5] = "June" month[6] = "July" month[7] = "August" month[8] = "September" month[9] = "October" month[10] = "November" month[11] = "December" var str ="getHours()/getMinutes()/getSeconds()/getMilliseconds()的现实集合" var minutes = 1000*60; var hour = minutes * 60; var day = hour * 24; var year = day *365; /*Date()方法可以返回当天的日期和时间*/ document.write("<p>Date()方法可以放回当天的日期和时间:"+Date()+"</p>"); /*getDate()方法可返回某月的某一天*/ /*dateObject.getDate() dateObject所指的月份中的某一天,返回值 1~31*/ document.write("<p>getDate()方法可返回某月的某一天:"+ d.getDate()+"</p>"); document.write("<p>getDate()预设Date值返回:"+birthday.getDate()+"</p>"); /*getDay()方法可返表示星期的某一天的数字*/ document.write("<p>getDate()方法可以返回某个星期的某一天:"+ d.getDay()+"</p>"); document.write("<p>getDate()方法先定义数组的:This is "+weekday[d.getDate()]+"</p>"); /*getMonth()方法可返回表示月份的数字*/ document.write("<p>getMonth()方法可返回表示某月的数字:"+ d.getMonth()+"<p>") document.write("<p>getMonth()方法返回预定义的数字: This is "+month[d.getMonth()]+"</p>") /*getFullYear()方法可返回一个表示年份的4位数字*/ document.write("<p>getFullYear()方法可返回年份:"+ d.getFullYear()+"</p>") document.write("<p>getFullYear()方法可返回生日年份:"+ birthday.getFullYear()+"</p>") /*getYear()方法可返回表示年份的两位数或四位数(一般使用getFullYear()方法替代)*/ /*对于介于 1900 与 1999 之间的年份,getYear() 方法仅返回两位数字。对于 1900 之前或 1999 之后的年份,则返回 4 位数字*/ document.write("<p>getYear()返回表示年份的两位数或四位数:"+ d.getYear()+"</p>") document.write("<p>getYear()返回表示年份的两位数或四位数:"+ birthday.getYear()+"</p>") /*getHours()/getMinutes()/getSeconds()/getMilliseconds()*/ document.write("<p>"+str.link("clock.html")+"</p>") /*getTime()方法可返回距离1970年1月1日之间的毫秒数*/ document.write("<p>"+ d.getTime()+" milliseconds since 1970/1/1</p>") document.write("<p>1970/1/1距离今天过了多少年:"+ (d.getTime())/year+"</p>")
0 0
- JavaScript date
- JavaScript Date
- javascript date
- Javascript --date
- javascript-date
- javascript.Date
- javascript Date()
- JavaScript Date
- JavaScript Date
- JavaScript Date
- JavaScript Date
- JavaScript.Date
- JavaScript Date
- javaScript Date
- java Date 和 javascript Date
- javascript的Date问题
- javascript常用对象 --- Date
- JavaScript Date 对象参考
- 整理SetupDixxx函数
- poj之旅——3368
- AngularJS 表格操作
- 解决jsp页面请求action后中文乱码的问题
- 原生对象
- JavaScript Date
- 天才小毒妃 > 第920章 被金执事威胁
- Java web工作原理
- 明月黄沙忆红颜
- libuv学习笔记(23)
- C语言实现六种排序算法
- 交叉编译环境
- html
- js,jquery常用方法