php求今天、昨天、明天时间戳的简单实现方法
本文实例讲述了php求今天、昨天、明天时间戳的简单实现方法。分享给大家供大家参考,具体如下:
echo strtotime('now'),'
';//现在
echo strtotime('today'),'
';//今天
echo strtotime('tomorrow'),'
';//明天
echo strtotime('yesterday'),'
';//昨天
运行结果如下:
1469674869
1469664000
1469750400
1469577600
今天剩余的秒数:
echo $time_remain = strtotime('tomorrow') - time();
//输出:75531
PS:本站还提供了一个Unix时间戳转换工具,非常实用,提供给大家参考:
Unix时间戳(timestamp)转换工具:http://tools.jb51.net/code/unixtime
更多关于PHP相关内容感兴趣的读者可查看本站专题:《php日期与时间用法总结》、《PHP数学运算技巧总结》、《PHP数组(Array)操作技巧大全》、《PHP数据结构与算法教程》、《php程序设计算法总结》、《php正则表达式用法总结》、《PHP运算与运算符用法总结》、《php字符串(string)用法总结》及《php常见数据库操作技巧汇总》
希望本文所述对大家PHP程序设计有所帮助。
时间: 2016-07-27
本文实例讲述了PHP获取昨天.今天及明天日期的方法.分享给大家供大家参考,具体如下: //PHP返回昨天的日期 function get_last_date() { $tomorrow = mktime(0,0,0,date("m"),date("d")-1,date("Y")); return date("Y-m-d", $tomorrow); } //PHP返回今天的日期 function get_today_date()
话不多说,请看代码: //获取今天 var nowDate= new Date(); //当天日期 console.log(nowDate); //今天是本周的第几天 var nowDayOfWeek= nowDate.getDay(); console.log(nowDayOfWeek); //当前日 var nowDay = nowDate.getDate(); console.log(nowDay); //当前月 var nowMonth = nowDate.getMonth(); con
1. 取今天时间 复制代码 代码如下: $date -d "now" +%Y-%m-%d 2. 取昨天时间 复制代码 代码如下: $date -d "yesterday" +%Y-%m-%d $date -d "1 days ago" +%Y-%m-%d ## -d, --date=STRING display time described by STRING, not `now' STRING可以为'now' . 'yest
复制代码 代码如下:
js获取日期:前天.昨天.今天.明天.后天 - Liehuo.Net