PHP编程获取各个时间段具体时间的方法
发布时间:2020-11-18 04:15:48 所属栏目:PHP 来源:互联网
导读:这篇文章主要介绍了PHP编程获取各个时间段具体时间的方法,结合实例形式分析了基于date与strtotime函数进行日期时间运算的相关操作技巧,需要的朋友可以参考下
本文实例讲述了PHP编程获取各个时间段具体时间的方法。分享给大家供大家参考,具体如下: ";
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"))." "; /* strtotime()函数的作用是将日期时间描述解析为 Unix 时间戳 int strtotime ( string time [,int now] ) */ ?> 运行结果如下: PS:这里再为大家推荐几款时间及日期相关工具供大家参考使用: 在线日期/天数计算器: 在线日期计算器/相差天数计算器: 在线日期天数差计算器: Unix时间戳(timestamp)转换工具: 更多关于PHP相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《》 希望本文所述对大家PHP程序设计有所帮助。 (编辑:甘南站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |