取得当前的Unix时间戳
从1970.1.1(00:00:00)—当前时间的秒数和
取得当前的日期
date();
date(时间戳的格式, 规定时间戳【默认是当前的日期和时间,可选】)
//date函数,第二个参数取默认值的情况
echo date("Y-m-d");//2014-03-30
//date函数,第二个参数有值的情况
echo date("Y-m-d",'1396193923');//2014-03-30,1396193923表示2014-03-30的unix时间戳
获取日期的时间戳
strtotime();
strtotime("2016-02-05");
strtotime("2016-2-5"); //测试也可行
将格式化的日期字符串转换成Unix时间戳
strtotime("now");
strtotime("+1 seconds");
strtotime("+1 day");
strtotime("+1 week");
strtotime("+1 week 3 days 7 hours 5 seconds");
格式化格林威治(GMT)标准时间
// gmdate()
//Y-m-d H:i:s
date_default_timezone_set("Asia/Shanghai");
echo date('Y-m-d H:i:s', time());
echo gmdate('Y-m-d H:i:s', time());