欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP---日期时间

程序员文章站 2022-05-10 14:53:13
...
取得当前的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:sdate_default_timezone_set("Asia/Shanghai");

echo date('Y-m-d H:i:s', time());

echo gmdate('Y-m-d H:i:s', time());
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了PHP---日期时间,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。