Give the start date and end date of the given date

xiaoxiao2021-03-05  23

/ *

* Function: Benefits the start date and end date of obtaining a given date

* Parameters: $ gdate date, default is the day, format: YYYY-MM-DD

* $ FIRST starts on Monday, Sunday, 0 is Sunday, 1 is Monday

* Return: Array Array ("Start Date", "End Date");

* Author: Multi-rookie

* Email: Kingerq at msn.com

* Source: http://blog.9cbs.net/kingerq

* /

Function Aweek ($ gdate = ", $ first = 0) {

IF (! $ gdate) $ gdate = date ("y-m-d");

$ w = Date ("W", Strtotime ($ gdate)); // Get a week's first few days, starting on Sunday 0-6

$ DN = $ W? $ W - $ first: 6; // To subtract the number of days

$ ST = DATE ("Y-M-D", Strtotime ("$ gdate -". $ DN. "days"));

$ en = DATE ("Y-m-D", Strtotime ("$ ST 6 Days"));

Return Array ($ ST, $ EN); // Return to start and end dates

}

Echo Implode ("|", aweek (", 1));

?>

转载请注明原文地址:https://www.9cbs.com/read-32285.html

New Post(0)