Home >Backend Development >PHP Tutorial >PHP实现根据时间戳获取周几的方法_PHP

PHP实现根据时间戳获取周几的方法_PHP

WBOY
WBOYOriginal
2016-05-27 10:35:33945browse

本文实例讲述了PHP实现根据时间戳获取周几的方法。分享给大家供大家参考,具体如下:

获取某个时间戳的周几,以及未来几天以后的周几 

其中:

$time 代表时间 

$i 今天开始 

具体示例代码如下:

function getTimeWeek($time, $i = 0) {
  $weekarray = array("一", "二", "三", "四", "五", "六", "日");
  $oneD = 24 * 60 * 60;
  return "周" . $weekarray[date("w", $time + $oneD * $i)];
}
$time=time();
echo getTimeWeek($tiem);

更多关于PHP相关内容感兴趣的读者可查看本站专题:《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn