Home >Backend Development >PHP Tutorial >PHP method to get the day of the week based on timestamp_php tips

PHP method to get the day of the week based on timestamp_php tips

PHP中文网
PHP中文网Original
2016-05-16 19:58:051302browse

The example in this article describes the method of obtaining the day of the week based on the timestamp in PHP. Share it with everyone for your reference, the details are as follows:

Get the day of the week of a certain timestamp, and the day of the week in the next few days

Among them:

$time represents Time

$i Starting today

The specific sample code is as follows:

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

I hope this article will be helpful to everyone in PHP programming.

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