A function isvaliddate ($date) needs to be written, as follows:
function isValidDate($date){ //1. $date 是本周时 + time()要在$date前一天的18:00之前 = true //2. $date 为下周时 + time()要在本周四下午六点后 = true //3. 其余返回false. (注:一周从周一开始)
Notes on PHP Development-commonly used date acquisition methods in weekly and weekly operations. This Monday echodate (Y-m-d, (time ()-(date (w) 0? 7: date (w)-1) * 24*3600); w is the number of the day of the week. Here 0 is the echodate (Y-m-d,
You need to write a function isValidDate ($ date) with the following conditions: {code ...} when I wrote the second condition, I found that the time covered by the condition seemed to be a bit problematic. I 'd like to see your opinions.
You need
Common date Operations
/**
* Get the start date of all weeks of the year
* @param $year format ' YYYY '
* Returns the two-dimensional array subscript key1 value corresponds to the actual year of the week of the year Key2
I made a simple program that originally meant output from Sunday to Saturday, but now I'm making a change in day and week, and the result I want is this:
2014-9-28 (Sunday)
2014-9-29 (Monday)
2014-9-30 (Tuesday)
2014-10-1 (Wednesday)
2014-10-2
Obtain the start date of the week based on the given date format & amp; apos; YYYY-mm-dd & amp; apos;
Common Date Operations
/**
* Get the start date of all weeks in a year
* @ Param $ year format 'yyyy'
* Returns
In fact, to be accurate to the week, that is, given the current time, know is the term of the first few weeks of school. The crux of the problem seems to be the lack of regularity, I am using the following code (PHP), the accuracy is not good enough:
In fact, it is accurate to the week, that is, given the current time, know the first week of the semester. the key to the problem seems to be that the rule is not found. I am using the following code (php), which is not accurate enough: {code ...}
Array: "Focus 1"Implode (delimited, arr) connects the array value data to the specified characters.
For example:
$arr =array (' 1 ', ' 2 ', ' 3 ', ' 4 ');
$str =implode ('-', $arr);
Explode ([delimited],arr) splits a string by the specified rule,
PHP Common Functions Summary sharing
For you to share PHP commonly used array, string, time, file operation function, I hope to learn PHP development of friends to help.
Array: "Focus 1" implode (delimited, arr) connects the array value data to
Monday
echo Date (' y-m-d ', (Time ()-((Date (' W ') ==0?7:date (' W ') ')-1) *24*3600)); W is the number form of the day of the week, where 0 is Sunday
This Sunday
echo Date (' y-m-d ', (Time () + (7-(' W ') ==0?7:date (' W ')) *24*3600)); Also
Ask for a
$week = Date (' W ');
function ($year, $week) return time of Monday;
Simultaneous solution
Date ("W", Strtotime (' 2011-1-1 ')) why not 1
Date ("W", Strtotime (' 2013-1-1 ')) why is 1
Reply content:
Ask for a
$week = Date (' W ')
Array: "Focus 1" implode (delimited, arr) concatenate the array value data by the specified character For example: $arr =array (' 1 ', ' 2 ', ' 3 ', ' 4 '); $str =implode ('-', $arr); Explode ([delimited],arr) splits a string by the specified
Use php to get the code for the date of this week, last week, this month, last month, and this quarter.
The code is as follows:
Echo date ("Ymd", strtotime ("now"), "\ n ";
Echo date ("Ymd", strtotime ("-1 week Monday"), "\ n ";
Echo date ("Ymd",
Php date processing code
Echo"";Echo date ("Y-m-d", strtotime ("now"), "\ n ";Echo"";Echo date ("Y-m-d", strtotime ("-1 week Monday"), "\ n ";Echo"";Echo date ("Y-m-d", strtotime ("-1 week Sunday"), "\ n
PHP obtains code for last week, this week, last month, this month, this quarter, and the last quarter.
Echo date ("Ymd", strtotime ("now"), "\ n ";
Echo date ("Ymd", strtotime ("-1 week Monday"), "\ n ";
Php output previous day last week last month last quarter
"; Echo date (" Y-m-d ", strtotime (" now ")," \ n "; echo""; Echo date (" Y-m-d ", strtotime ("-1 week Monday ")," \ n "; echo""; Echo date (" Y-m-d ", strtotime ("-1 week Sunday ")," \ n "
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.