How does PHP obtain the date list for a period of time. Recently, I am working on a calendar project to provide a start time and end time. I need to list the dates in this time period and determine the number of weeks at the same time. After research, we have to work on a calendar project recently to provide a start time and end time. we need to list the dates in this period and determine the day of the week at the same time. After research, we have obtained the following method to share it with you to make it easy for you to have friends in need.
First, post the following requirements:
The following is a specific code snippet:
/** Parameters are respectively the start timestamp and end timestamp */function timeList ($ beginTimeStamp, $ endTimeStamp) {if (! Is_numeric ($ beginTimeStamp) |! Is_numeric ($ endTimeStamp) | ($ endTimeStamp <= $ beginTimeStamp) return ''; $ tmp = array (); for ($ I = $ beginTimeStamp; $ I <= $ endTimeStamp; $ I ++ = (24*3600) {$ tmp ['timestamplist'] [] = $ I; $ tmp ['daylist'] [] = date ('y, m, dday', $ I ); $ tmp ['dayweek'] [] = getWeek ($ I);} return $ tmp;} function getWeek ($ timestamp) {$ timestamp = date ('W ', $ timestamp); $ str = ''; // http://www.phpernote.com/php-function/969.htmlswitch ($ timestamp) {case '0': $ str. = 'Sunday'; break; case '1': $ str. = 'Monday'; break; case '2': $ str. = 'tues'; break; case '3': $ str. = 'wedne'; break; case '4': $ str. = 'thurs'; break; case '5': $ str. = 'Friday'; break; case '6': $ str. = 'Saturday'; break;} return $ str ;}Articles you may be interested in
- Php gets the method of each month in a certain period of time, and returns an array composed of these months
- Php obtains the start and end timestamps of today, yesterday, last week, and this month.
- PHP retrieves the date list for the first 30 days of the current date
- Why are there always errors between the programmer's estimated time and the actual project completion time?
- PHP implements real-time output of results to the browser
- Solution to an eight-hour difference in the date time in php
- Php extracts the birthday date from the ID card number and verifies whether it is a minor.
- Php retrieves and outputs a list of all images in the content
Bytes. After research...