This article brings you the content is about PHP to obtain a variety of time summary (code), there is a certain reference value, the need for friends can refer to, I hope to help you.
Get system time
Such as: The day before the system, the current time of the week Monday time, etc.
1. Get the current time of the system
echo "Date (' y-m-d ', Time ())";
2. Get the System one day before the time
echo "Date" ("Y-m-d", Strtotime ("-1 Day")) "; Minus (-) a few days before it takes a few days to add (+)
3. Get current system time last week of Monday and Sunday of the day
The date of last Sunday is $lastsunday = Date (' y-m-d ', Strtotime ('-1 Sunday ', Time ())),///based on the time difference minus 6 days ago, calculated last week 1st period $lastmonday = Date (' y-m-d ', Strtotime (' $lastSunday-6 day ', $SS));
4. Get the day of the current week Sunday is 0 weeks a to Saturday is 1-6
$today = Date (' y-m-d ', Time ()); Gets the day ordinal of the current week Sunday is 0 weeks a to Saturday is 1-6 $w =date (' W ', Strtotime ($today)); $first =1; Gets the start date of the week, if $w is 0, then represents Sunday, minus 6 days $weekStart =date (' y-m-d 00:00:00 ', Strtotime ("$today-". $w? $w-$first: 6). ' Days '); This week's end date $weekEnd =date (' y-m-d 23:59:59 ', Strtotime ("$weekStart +6 Days"); The start time of the previous week $weekStart = Date (' y-m-d 00:00:00 ', Strtotime ("$weekStart-7 Days"); $weekEnd = Date (' y-m-d 23:59:59 ', Strtotime ("$weekEnd-7 Days")););
5. How many days in the last one months
$t = date (' t ', Strtotime ('-1 month '));
Related recommendations:
Implementation code of FTP upload and download function in PHP
PHP implementation of File upload and download method (code)