在php中可以通过strtotime函数将任何英文文本的日期或时间描述解析为Unix时间戳,其转换语法如“strtotime(time,now);”。

本文操作环境:windows7系统、PHP7.1版,DELL G3电脑
php怎么时间转unix时间?
strtotime() 函数将任何英文文本的日期或时间描述解析为 Unix 时间戳(自 January 1 1970 00:00:00 GMT 起的秒数)。
注意:如果年份表示使用两位数格式,则值 0-69 会映射为 2000-2069,值 70-100 会映射为 1970-2000。
立即学习“PHP免费学习笔记(深入)”;
注意:请注意 m/d/y 或 d-m-y 格式的日期,如果分隔符是斜线(/),则使用美洲的 m/d/y 格式。如果分隔符是横杠(-)或者点(.),则使用欧洲的 d-m-y 格式。为了避免潜在的错误,您应该尽可能使用 YYYY-MM-DD 格式或者使用 date_create_from_format() 函数。
语法
strtotime(time,now);
参数
TGroupon团购系统是以php+MySQL进行开发的团购网站系统,首页能同时显示多个正在进行中的团购商品,将团购中的商品最大限度的展示在用户面前,对提升网站整体销售量有着很大的帮助。安装说明:1:环境:windows/LINUX/UNIX/apache,mysql,php2:所用语言: php,javascript,xml,html3:将程序放置空间或者服务器上,要求uploadfiles目录
time 必需。规定日期/时间字符串。
now 可选。规定用来计算返回值的时间戳。如果省略该参数,则使用当前时间。
实例
将英文文本日期时间解析为 Unix 时间戳:
");
echo(strtotime("15 October 1980") . "
");
echo(strtotime("+5 hours") . "
");
echo(strtotime("+1 week") . "
");
echo(strtotime("+1 week 3 days 7 hours 5 seconds") . "
");
echo(strtotime("next Monday") . "
");
echo(strtotime("last Sunday"));
?>运行结果:
1624501241247 1473004800 1624519247 1625106047 1625390452 1624809600 1624118400
推荐学习:《PHP视频教程》










