This article introduces how PHP gets the time
$year = Date ("Y");//year 2018 if "Y" is lowercase, the output is shorthand for the year, such as: 2018, the output is: 18$month =date ("M");//month 2 if "M" uppercase, the output is the English month, lowercase is the number of the date of the =date ("D"); $week =date ("L");//day of the Week $last_month_days = Cal_days_in_month (Cal_gregorian, $month-1, $year);//number of days on January $month = Date (" M ") $now _month_days = Cal_days_in_month (Cal_gregorian, $month, $year);//number of days of the current month; $month = Date (" M ") cal_days_in_month public : Returns the number of days of a month in a calendar year $next_month_days=cal_days_in_month (Cal_gregorian, $month +1, $year); if ($year%4==0 && $now _ month_days==28) {$now _month_days = $now _month_days+1;//judge that the current month is not a leap year, that is, February plus one day, that is, 29 days} $week _date = Date ("W", Strtotime (" 2018-2-5 ")); The string specifies the date to get the day of the Week $week_date = Date ("W", Strtotime (Date ("y-m-d)"); variable specifies the day of the Week $week_date = Date ("W", Strtotime ($year. " -". $month." -"." 1 "));//splicing string specifies the monthly period of 1th, the day of the week Cal_days_in_month public: Returns the number of days of a month in a calendar
Parameter description:
Cal_days_in_month (PAR1,PAR2, $par 3);
$par 1: A calendar for calculation, PHP calendar constant
PAR2: Parameter Par1 Select a month in the calendar
$par 3: Select a year in the calendar
return value:
$par 1 days of the month of the selected calendar
PHP Calendar constants: The calendar extension contains functions that simplify conversion between different calendar formats.
In order for these functions to work, you must compile PHP through –enable-calendar. window, the support for calendar extensions has been integrated
The constants in the case are Cal_gregorian, which are predefined constants of PHP, like constants such as Php_os
Gregorian means: Gregorian calendar; Solar Calendar
This article introduces the method of PHP acquisition time, more relevant content please follow the PHP Chinese web.