时间字符串解析成⽇期时间格式 1 <script>
2function secToDate(sec){
3var now=new Date(sec);
4var FullYear();
5var Month()+1;
6var Date();
7var Day();
8var Hours();
9var Minutes();
10var Seconds();
11var days=["⽇","⼀","⼆","三","四","五","六"];
12        hh=(hh<9)?"0"+hh:hh;
13        mm=(mm<9)?"0"+mm:mm;
14return {
15            bookTime:y+"-"+m+"-"+d+" 周"+days[day]+" "+hh+":"+mm,
16            serviceTime:y+"-"+m+"-"+d+" "+hh+":"+mm
17        }
18    }
19var date=secToDate(1476762967406);
20var date2=secToDate(1476768453057);
21    console.log('预约时间:'+date.bookTime);
22    console.log('服务时间:'+date2.serviceTime);
23 </script>
获取天数
//得到某天的⽇期
function GetDateStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var y = dd.getFullYear();
var m = dd.getMonth()+1;//获取当前⽉份(0-11,0代表1⽉)
m = m<10?"0"+m:m;
var d = dd.getDate();
d = d<10? "0"+d : d;
return y+"-"+m+"-"+d;
}
//得到某天⽇期的“年”(2位)
function GetYearStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
Year();
}
//得到某天⽇期的“年”(4位)
function GetFullYearStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
FullYear();
}
//得到某天⽇期的“⽉”
function GetMonthStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var m = dd.getMonth()+1;//获取当前⽉份(0-11,0代表1⽉)
m = m<10?"0"+m:m;
return m;
}
/
/得到某天⽇期的“⽇”
function GetDStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var d = dd.getDate();
d = d<10? "0"+d : d;
return d;
交易时间字符串是什么}
//得到某天⽇期的“周⼏”
function GetDayStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var days=["⽇","⼀","⼆","三","四","五","六"];
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
return Day()];  //获取当前星期X(0-6,0代表星期天)
}
//得到某天⽇期的“毫秒数”
function GetTimeStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
Time();//获取当前时间(从1970.1.1开始的毫秒数)
}
//得到某天⽇期的“⼩时”
function GetHoursStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var h = dd.getHours();//获取当前⼩时数(0-23)
h = h<10? "0"+h : h;
return h;
}
//得到某天⽇期的“分钟”
function GetMinutesStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var  m  =dd.getMinutes();//获取当前分钟数(0-59)
m = m<10?"0"+m:m;
return m;
}
//得到某天⽇期的“秒数”
function GetSecondsStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var  s  =dd.getSeconds();////获取当前秒数(0-59)
s = s<10?"0"+s:s;
return s;
}
//得到某天⽇期的“毫秒数”
function GetMillisecondsStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
var  ms  =dd.getMilliseconds();//获取当前毫秒数(0-999)
ms = ms<10?"0"+ms:ms;
return ms;
}
//得到某天的⽇期
function GetLocaleDateStr(AddDayCount) {
/
/获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
LocaleDateString();//获取当前⽇期
}
//得到某天的时间
function GetLocaleTimeStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
LocaleTimeString();//获取当前时间
}
//得到某天的⽇期与时间
function GetLocaleStr(AddDayCount) {
//获取AddDayCount天后的⽇期
var dd = new Date(new Date().getTime() + AddDayCount*24*60*60*1000);
LocaleString();//获取⽇期与时间
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。