How to obtain the date list for a period of time in PHP _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.