js时间处理函数
Date 对象的方法简介:
·Date | 返回当日的日期和时间
·getDate | 从 Date 对象返回一个月中的某一天 (1 ~ 31)
·getDay | 从 Date 对象返回一周中的某一天 (0 ~ 6)
·getFullYear | 根据本地时间获取当前年份(四位数字)
·getHours | 根据本地时间获取当前小时数(24小时制,0-23)
·getMilliseconds | 根据本地时间获取当前毫秒数(0 ~ 999)
·getMinutes | 根据本地时间获取当前分钟数(0 ~ 59)
·getMonth | 从 Date 对象返回月份 (0 ~ 11)
·getSeconds | 根据本地时间获取当前秒数(0 ~ 59)
·getTime | 获取UTC(世界时间)格式的从1970.1.1 0:00以来的毫秒数
·getTimezoneOffset | 获取当前时间和UTC格式的偏移值(以分钟为单位)
·getUTCDate | 获取UTC格式的当前日期(本月的几号)
·getUTCDay | 获取UTC格式的今天是星期几(0 ~ 6)
·getUTCFullYear | 获取UTC格式的当前年份(四位数字)
·getUTCHours | 获取UTC格式的当前小时数(24小时制,0-23)
·getUTCMilliseconds | 获取UTC格式的当前毫秒数
·getUTCMinutes | 获取UTC格式的当前分钟数
·getUTCMonth | 获取UTC格式的当前月份(注意从0开始:0-Jan,1-Feb...)
·getUTCSeconds | 获取UTC格式的当前秒数
·getYear | 根据本地时间获取当前缩写年份(当前年份减去1900)
·setDate | 设置当前日期(本月的几号)
·setFullYear | 设置当前年份(四位数字)
·setHours | 设置当前小时数(24小时制,0-23)
·setMilliseconds | 设置当前毫秒数
·setMinutes | 设置当前分钟数
·setMonth | 设置当前月份(注意从0开始:0-Jan,1-Feb...)
·setSeconds | 设置当前秒数
·setTime | 设置UTC格式的从1970.1.1 0:00以来的毫秒数
·setUTCDate | 设置UTC格式的当前日期(本月的几号)
·setUTCFullYear | 设置UTC格式的当前年份(四位数字)
·setUTCHours | 设置UTC格式的当前小时数(24小时制,0-23)
·setUTCMilliseconds | 设置UTC格式的当前毫秒数
·setUTCMinutes | 设置UTC格式的当前分钟数
·setUTCMonth | 设置UTC格式的当前月份(注意从0开始:0-Jan,1-Feb...)
·setUTCSeconds | 设置UTC格式的当前秒数
·setYear | 设置当前缩写年份(当前年份减去1900)
·toString | 将日期时间值转换成"日期/时间"形式的字符串值
·Date.UTC | 返回指定的UTC格式日期时间的固定时间值
创建新的 Date 对象
语法:
new Date();
new Date(year [, month [, date [, hour [, minute [, second [, millisecond ]]]]]] );
参数:
year 是一个 0 到 99 之间的整数,对应于 1900 到 1999 年,或者为四位数字指定确定的年份;
month 是一个 0 (一月) 到 11 (十二月) 之间的整数,这个参数是可选的;
date 是一个 1 到 31 之间的整数,这个参数是可选的;
hour 是一个 0 (0:00am) 到 23 (11:00pm) 之间的整数,这个参数是可选的;
minute 是一个 0 到 59 之间的整数,这个参数是可选的;
second 是一个 0 到 59 之间的整数,这个参数是可选的;
millisecond 是一个 0 到 999 之间的整数,这个参数是可选的;
js时间处理函数的更多相关文章
- js时间格式化函数,支持Unix时间戳
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- JS 时间格式化函数
//时间格式化函数 Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, ...
- js 时间日期函数小结
Date.prototype.format = function(format){ var o = { "M+" : this.getMonth()+1, //month &quo ...
- JS 时间转换函数 字符串时间转换毫秒(互转)
字符串转化为日期 let util = function(){ Date.prototype.Format = function(fmt) { var o = { "M+" : t ...
- js时间格式化函数(兼容IOS)
* 时间格式化 * @param {Object} dateObj 时间对象 * @param {String} fmt 格式化字符串 */ dateFormat(dateObj, fmt) { le ...
- js 时间处理函数 获取今天的前几天和后几天的任意一天
var now = new Date(); let today = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDa ...
- js 时间处理函数 (判断今天是否在一段时间内)
var curTime = new Date(); //2把字符串格式转换为日期类 var startTime = new Date(Date.parse("2018-3-28 16:44& ...
- JS时间格式化函数
Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month & ...
- js 时间日期函数
忘记从哪里拷贝过来的了,侵删 Date.prototype.format = function (format) { var date = { "M+": this.getMont ...
随机推荐
- URLError 异常处理
3 URLError 首先解释下 URLError 可能产生的原因: 网络无连接,即本机无法上网 连接不到特定的服务器 服务器不存在 在代码中,我们需要用 try-except 语句来包围并捕获相应的 ...
- asp.net LINQ LinqDataSource控件显示数据和DropdownList显示数据
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.We ...
- javascript 中的继承实现, call,apply,prototype,构造函数
javascript中继承可以通过call.apply.protoperty实现 1.call call的含义: foo.call(thisObject, args...) 表示函数foo调用的时候, ...
- 方法的覆盖(override)、重载(overload)和重写(overwrite)
body { background-color: white } .markdown-body { min-width: 200px; max-width: 760px; margin: 0 auto ...
- 【python】迭代器&生成器
源Link:http://www.cnblogs.com/huxi/archive/2011/07/01/2095931.html 迭代器 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素 ...
- Ubuntu:我不小心把/var/lock文件夹给删了
在一个风和日丽的下午,不正常关闭minicom导致了device 没有正常解锁,于是使用minicom的时候提示 device is locked: 根据网上看到的方法只要把/var/lock 里面的 ...
- 如何让textarea不可拖拽
文本域textarea有一个特性,就是可以拖拽改变其大小,但是在布局严格要求的页面中,这种特性显然会影响布局. 一行代码就可以搞定: textarea{ resize:none;} 但是在chrome ...
- [转]CryptographyHelper.cs
using System; using System.IO; using System.Security.Cryptography; using System.Text; public class C ...
- 安卓app中嵌入一个H5页面,当手机系统设置字体变大时,如何使H5页面的字体不会随用户自己调整的系统字体变化而变化?
webview.getSettings().setTextZoom(100);WebView加上这个设置后,WebView里的字体就不会随系统字体大小设置发生变化了. https://segmentf ...
- C#获取程序集自动增加的版本号和编译时间
1. 首先找到文件AssemblyInfo.cs, 路径如下: 2. 修改版本的格式,修改后,程序每次编译,程序集的版本号都会自增. 修改前: [assembly: AssemblyVersion(& ...