js获取当地时间并且拼接时间格式,在stackoverflow上有人在问,查了资料,各种方法将时间格式改成任意自己想要的样式。
1.
- var date = new Date(+new Date()+8*3600*1000).toISOString().replace(/T/g,' ').replace(/.[d]{3}Z/,'');
- console.log(date);//2017-01-22 11:08:46
- var date = new Date();
- var strDate = date.toLocaleString().replace(/[年月]/g,'-').replace(/[日上下午]/g,'');
- console.log(strDate);// 2017/1/22 11:11:56
- function getNowFormatDate() {
- var date = new Date();
- var seperator1 = "-";
- var seperator2 = ":";
- var month = date.getMonth() + 1;
- var strDate = date.getDate();
- if (month >= 1 && month <= 9) {
- month = "0" + month;
- }
- if (strDate >= 0 && strDate <= 9) {
- strDate = "0" + strDate;
- }
- var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
- + " " + date.getHours() + seperator2 + date.getMinutes()
- + seperator2 + date.getSeconds();
- return currentdate;
- }
- var data = getNowFormatDate();
- console.log(data); //2017-01-22 11:14:16
npm无法安装node-sass的解决方法
rem
创建和存储 cookie
webpack学习(一):webpack的安装和命令行
gulp常用的插件
移动前端开发之viewport的深入理解
JavaSE中Collection集合框架学习笔记(3)——遍历对象的Iterator和收集对象后的排序
JavaSE中Collection集合框架学习笔记(2)——拒绝重复内容的Set和支持队列操作的Queue
JavaSE中Collection集合框架学习笔记(1)——具有索引的List