1.当前时间换时间戳 var timestamp = parseInt(new Date().getTime()/1000); // 当前时间戳 document.write(timestamp); 2.当前时间换日期字符串 var now = new Date(); var yy = now.getFullYear(); //年 var mm = now.getMonth() + 1; //月 var dd = now.getDate(); //日 var hh = now.getHours(
//日期加天数的方法 //dataStr日期字符串 //dayCount 要增加的天数 //return 增加n天后的日期字符串 function dateAddDays(dataStr,dayCount) { var strdate=dataStr; //日期字符串 var isdate = new Date(strdate.replace(/-/g,"/")); //把日期字符串转换成日期格式 isdate = new Date((isdate/1000+(86400*dayCou
字符串形如:2016-06-20 10:41 转换为时间戳: var date = "2016-06-20 10:41"; date = date.substring(,); date = date.replace(/-/g,"/"); var timestamp = new Date(date).getTime(); console.log(timestamp/)
本文转自:https://blog.csdn.net/Lc_style/article/details/80626748 1.将日期格式转化为时间戳: var date = new Date('2018-06-08 18:00:00'); // 有三种方式获取 var time1 = date.getTime(); var time2 = date.valueOf(); var time3 = Date.parse(date); console.log(t
//获取当前时间: var myDate = new Date();//当前时间 var year = myDate.getFullYear();//当前年份 var month = myDate.getMonth() + 1;//当前月份 var day = myDate.getDate();//当前日 myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); //获取完整的年份(4位,1970-????) myDate.getMonth();
2014-04-23 18:55:49:123 日期格式 1398250549123 时间戳格式 前台显示日期格式,则 function tsToTime(ts) { var date = new Date(ts * 1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1)
//把日期转换成时间戳 function get_unix_time(time1){ var newstr = time1.replace(/-/g,'/'); var date = new Date(newstr); var time_str = date.getTime().toString(); return time_str.substr(0, 10);} 一.时间转换时间戳 function transdate(endTime){ var date=new