How to get the day of the week based on timestamp in PHP

WBOY
Release: 2016-07-29 09:01:12
Original
1037 people have browsed it

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, 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

Specific example code 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);

Copy after login

Readers who are interested in more PHP-related content can check out the special topics of this site: "Summary of PHP Date and Time Usage", "Introduction to PHP Object-Oriented Programming Tutorial", "php String Usage" Summary", "Introduction Tutorial on PHP+MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

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

The above introduces the method of obtaining the day of the week based on the timestamp in PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!