//一、获取当前时间戳
方法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()),"
";
echo "今天:",date("Y-m-d",strtotime("18 june 2008")),"
";
echo "昨天:",date("Y-m-d",strtotime("-1 day")), "
";
echo "明天:",date("Y-m-d",strtotime("+1 day")), "
";
echo "一周后:",date("Y-m-d",strtotime("+1 week")), "
";
echo "一周零两天四小时两秒后:",date("Y-m-d G:H:s",strtotime("+1 week 2 days 4 hours 2 seconds")), "
";
echo "下个星期四:",date("Y-m-d",strtotime("next Thursday")), "
";
echo "上个周一:".date("Y-m-d",strtotime("last Monday"))."
";
echo "一个月前:".date("Y-m-d",strtotime("last month"))."
";
echo "一个月后:".date("Y-m-d",strtotime("+1 month"))."
";
echo "十年后:".date("Y-m-d",strtotime("+10 year"))."
";

jquery.min.js








js部分

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);

}