php时间戳添加时分秒等偏移

我们使用time()可以打印出时间戳,但是我们想要加个偏移,比如用于缓存等,我们就要添加时分秒的偏移,可以用下边的代码实现

        echo time() , "<br/>";

        echo strtotime("+1 minute"), "<br/>";

        echo strtotime("+120 seconds"), "<br/>";

        echo strtotime("now"), "<br/>";

        echo strtotime("10 September 2000"), "<br/>";

        echo strtotime("+1 day"), "<br/>";

        echo strtotime("+1 week"), "<br/>";

        echo strtotime("+1 week 2 days 4 hours 2 seconds"), "<br/>";

        echo strtotime("next Thursday"), "<br/>";

        echo strtotime("last Monday"), "<br/>";

打印结果如下:

1655117721
1655117781
1655117841
1655117721
968515200
1655204121
1655722521
1655909723
1655308800
1654444800

暂无评论

相关推荐

php 脚本指定参数

<?php $param_arr = getopt('a:b:'); $a = $param_arr['a'] 调用 php script.php -av1 -bv2 注 …

php重新安装curl扩展

因为我们的php不支持https,所以我们需要重新编译php,不过因为我们用的是M1,有一些问题待解决,最终失败在了php安装 …

服务器配置查询

nginx的配置查询 nginx -t 打印: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configu …

微信扫一扫,分享到朋友圈

php时间戳添加时分秒等偏移