获取今天的日期(年月日时分秒)、获取今天昨天明天的日期
1、获取今天的日期(年月日时分秒)
getCurrentTime() {let yy = new Date().getFullYear();let mm = new Date().getMonth()+1;let dd = new Date().getDate();let hh = new Date().getHours();let mf = new Date().getMinutes()<10 ? '0'+new Date().getMinutes() : new Date().getMinutes();let ss = new Date().getSeconds()<10 ? '0'+new Date().getSeconds() : new Date().getSeconds();this.gettime = yy+'/'+mm+'/'+dd+' '+hh+':'+mf+':'+ss;console.log(this.gettime) }
2、获取昨天今天明天
mounted () {
console.log('昨天:', this.getDay(-1, 7200000))
console.log('今天:', this.getDay(0, 3600000))
console.log('明天:', this.getDay(1, 3600000))
console.log('一周后:', this.getDay(7, 7200000)
},
getDay (day, hours) {
var today = new Date()
var targetday = today.getTime() + 1000 * 60 * 60 * 24 * day + hours
today.setTime(targetday)
var tYear = today.getFullYear()
var tMonth = today.getMonth()
var tDate = today.getDate()
var getHours = today.getHours()
tMonth = this.doHandleMonth(tMonth + 1)
tDate = this.doHandleMonth(tDate)
return tYear + '-' + tMonth + '-' + tDate + '小时:' + getHours
},
doHandleMonth (month) {
var m = month
if (month.toString().length === 1) {
m = '0' + month
}
return m
}
获取今天的日期(年月日时分秒)、获取今天昨天明天的日期相关推荐
- js获取当前时间的年月日时分秒以及时间的格式化
1.获取当前时间 var myDate = new Date(); 2.获取时间中的年月日时分秒 myDate.getYear(); // 获取当前年份(2位) myDate.getFullYear( ...
- python 获取当前时间(年月日时分秒)
python 获取当前时间(年月日时分秒) now_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime())
- JAVA 获取当前时间(年月日时分秒)
LocalDateTime单独获取年月日和时分秒 LocalDateTime localDateTime = LocalDateTime.now(); localDateTime.format(Dat ...
- JS获取当前时间(年月日时分秒)
JS获取当前时间(年月日时分秒) JS获取当前时间(年月日时分秒) 代码直接撸: **拿走直接用 `//获取当前时间 getNowTime() { var date = new Date(); //年 ...
- php获取当前时间的年月日时分秒格式
php获取当前时间的年月日时分秒 解决方法: $now_time= time(); 年月日时分秒格式:http://www.yayihouse.com/yayishuwu/chapter/1727
- 时间戳与日期年月日时分秒的转换
在前端的日常工作当中,时间戳的使用也是不少的.有时后端返回给我们的数据是一个时间戳,我们需要转换成年月日,时分秒的形式展示在页面当中,为了以后的使用方便,我在这里简单写了个函数来进行转换. 1.是时间 ...
- jq weui 日期年月日时分秒得设置(二个弹窗)
需求:h5页面需要年月日时分秒, 方法:weui得datePicker插件只有年月日得,所以时分秒就要单独用picker插件单独配置一个,网上有类似得,难点就在于在第一个年月日关闭后就弹出时分秒得弹框 ...
- datepick二格式 化时间_My97DatePicker设置日期年月日时分秒格式
前端 JavaScript 日期插件 My97DatePicker 非常出名.N多年以前我就使用过,当时下载了之后,使用的时候默认是没有小时,分钟,秒之类的,直接是年月日的日期格式,跟一般的日期插件没 ...
- html时间日期 年月日时分秒,年月日时分秒的即时显示
网页特效观止|JsCode.CN|---年月日时分秒的即时显示 var timerID = null; var timerRunning = false; function stopclock (){ ...
- c#.net 获取时间日期年月日时分秒生成自动文件名格式
下面是日期和时间的各种方法,转换为字符串. 如果把输出的格式改下就可以做类似的文件名了,例如:2016010110101224356.doc c#用DateTime.Now.ToString(&qu ...
最新文章
- Python PK C++,究竟谁更胜一筹?
- python篮球-基于Python/Java的人工智能篮球训练系统的制作方法
- Java数据库连接池实现原理
- (chap6 Http首部) 首部字段概论
- html显示假的图片路径,实现自己网站的图片假水印功能
- DeepLearning:手动编辑python实现卷积操作
- goahead php,Goahead移植教程 | 学步园
- eclipse插件安装,万能方法
- 数据结构之线段树Ⅴ——(李超线段树)Robot,Product Sum,Building Bridges,Jump mission
- spring bean配置_在运行时交换出Spring Bean配置
- 【渝粤题库】陕西师范大学201661英语阅读(二)作业(高起专)
- Redis数据库学习笔记
- extjs中元数据_json – 如何配置ExtJS 4 Store(代理和阅读器)来读取元数据
- Intel Core Enhanced Core架构/微架构/流水线 (15) - 先进智能缓存
- 用MySQl创建供应商标_建立一个供应商、零件数据库。其中供应商表S(Sno,Sname,Zip - 问答库...
- 【语音编码】基于matlab ADPCM编解码【含Matlab源码 553期】
- IOS - 苹果微信不打开收不到新消息提醒怎么办?
- UVALive-3713 Astronauts (2-SAT)
- 小米论坛php,黑橙新版小米社区discuz模板
- Win键失效,Win+L不起作用了