码迷,mamicode.com
首页 > Web开发 > 详细

获取当前 系统时间 + 获取当前url 键值;

时间:2017-03-23 11:36:19      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:cond   span   当前时间   min   时间   oca   second   query   seconds   

一:

//系统当前时间
function show(){
var mydate = new Date();
var str = "" + mydate.getFullYear() + "年";
str += (mydate.getMonth()+1) + "月";
str += mydate.getDate() + "日";
str+=mydate.getHours() + "时";
str+=mydate.getMinutes() + "分";
str+=mydate.getSeconds() + "秒";
return str;


}
function show1(){
function p(s) {
return s < 10 ? ‘0‘ + s: s;
}

var myDate = new Date();
//获取当前年
var year=myDate.getFullYear();
//获取当前月
var month=myDate.getMonth()+1;
//获取当前日
var date=myDate.getDate();
var h=myDate.getHours(); //获取当前小时数(0-23)
var m=myDate.getMinutes(); //获取当前分钟数(0-59)
var s=myDate.getSeconds();

var now=year+‘-‘+p(month)+"-"+p(date)+" "+p(h)+‘:‘+p(m)+":"+p(s);
return now;

}
console.log(show1())
console.log(show())

输出结果:

技术分享

 

非 原创;





二:

getQueryString:function(name){
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
//console.log(r,‘url‘)
if (r != null && r != undefined) {
return unescape(r[2]);
}else{
return null;
}
},


ps:name 为 键值;
 

获取当前 系统时间 + 获取当前url 键值;

标签:cond   span   当前时间   min   时间   oca   second   query   seconds   

原文地址:http://www.cnblogs.com/Pirate630/p/6604088.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!