Home > Article > Backend Development > How to get the day of the week based on timestamp in PHP
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);
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.