//一、获取当前时间戳
方法1:通过time函数
1 time();
方法2:通过$_SERVER中的REQUEST_TIME元素
$_SERVER['REQUEST_TIME'];
方法3:通过strtotime函数
strtotime('now'));
二、获取当前时间
通过date函数格式化时间戳
1 echo date('Y-m-d h:i:s', time()); // 2016-12-31 05:07:05

date_default_timezone_set('PRC'); //默认时区
echo "今天:",date("Y-m-d",time()),"<br>";
echo "今天:",date("Y-m-d",strtotime("18 june 2008")),"<br>";
echo "昨天:",date("Y-m-d",strtotime("-1 day")), "<br>";
echo "明天:",date("Y-m-d",strtotime("+1 day")), "<br>";
echo "一周后:",date("Y-m-d",strtotime("+1 week")), "<br>";
echo "一周零两天四小时两秒后:",date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")), "<br>";
echo "下个星期四:",date("Y-m-d",strtotime("next Thursday")), "<br>";
echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."<br>";
echo "一个月前:".date("Y-m-d",strtotime("last month"))."<br>";
echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."<br>";
echo "十年后:".date("Y-m-d",strtotime("+10 year"))."<br>";

jquery.min.js
<tr>
<td style="width:13%; text-align: right;">
<label >姓名
</label>
</td>
<td style="width:87%;">
<input type="text" name="username" value="" id="User_username" onkeyup="this.value=this.value.replace(/\s+/g,'')" placeholder="4-15位用户名"/>
<span class="uer_class"></span>
</td>
</tr>

js部分
<script type="text/javascript" src="PUBLIC/js/jquery.min.js"></script>
<script type="text/javascript">
$(function (){
var user_Boolean = false;
$("#User_username").blur(function (){
var name = $("#User_username").val();
if(name != ''){
var url ='checknm';
var data ={"name":name};
var success =function (response){
if(response.error == 0){
$('.uer_class').html("已经存在用户").css("color","red");
user_Boolean = false;
}
if(response.error == 1){
$('.uer_class').html("✔可以使用").css("color","green");
user_Boolean = true;
}
}
$.post(url,data,success,"json");
}else{
$('.uer_class').html("请输入用户名").css("color","red");
user_Boolean = false;
}
});

$('.red_button').click(function(){ if(user_Boolean == true){ alert("注册成功"); $("form").submit(); }else { alert("请完善信息"); } }); }); </script> php后台部分 function checknm($name){ $info = D('user')->where("user_name ='$name'")->find(); if($info){ $response = array( 'error'=>0, 'errmsg'=>'用户已经存在', 'data' =>false ); }else{ $response = array( 'error'=>1, 'errmsg'=>'可以使用', 'data' =>true ); } echo json_encode($response);

}