js获取时间的函数集

Posted 会飞的小蜜蜂

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了js获取时间的函数集相关的知识,希望对你有一定的参考价值。

var mydate = new Date();
mydate.getYear(); //获取当前年份(2位)
mydate.getFullYear(); //获取完整的年份(4位,1970-????)
mydate.getMonth(); //获取当前月份(0-11,0代表1月)
mydate.getDate(); //获取当前日(1-31)
mydate.getDay(); //获取当前星期X(0-6,0代表星期天)
mydate.getTime(); //获取当前时间(从1970.1.1开始的毫秒数)
mydate.getHours(); //获取当前小时数(0-23)
mydate.getMinutes(); //获取当前分钟数(0-59)
mydate.getSeconds(); //获取当前秒数(0-59)
mydate.getMilliseconds(); //获取当前毫秒数(0-999)
mydate.toLocaleDateString(); //获取当前日期
var mytime=mydate.toLocaleTimeString(); //获取当前时间
mydate.toLocaleString( ); //获取日期与时间


日期时间脚本库方法列表

Date.prototype.isLeapYear 判断闰年
Date.prototype.Format 日期格式化
Date.prototype.DateAdd 日期计算
Date.prototype.DateDiff 比较日期差
Date.prototype.toString 日期转字符串
Date.prototype.toArray 日期分割为数组
Date.prototype.DatePart 取日期的部分信息
Date.prototype.MaxDayOfDate 取日期所在月的最大天数
Date.prototype.WeekNumOfYear 判断日期所在年的第几周
StringToDate 字符串转日期型
IsValidDate 验证日期有效性
CheckDateTime 完整日期时间检查
daysBetween 日期天数差

 































以上是关于js获取时间的函数集的主要内容,如果未能解决你的问题,请参考以下文章

获取数据集matlab的尺寸,尺寸函数

js基本函数

Tkinter:获取数据集的单选按钮和查找数据集之间匹配和不匹配的函数

js函数

R语言使用data函数获取当前R环境可用的示例数据集:获取datasets包中的所有示例数据集获取所有包的数据集获取特定包的数据集

从 Spring JAVA 中的 oracle PLSQL 函数获取结果集时出错