Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn about php to get the date of a certain day of the specified month.
/**
* Get the day of the specified month
* @ $ Year, $ month, $ day, $ format displays the format of time, $ last indicates the last day of the month
* @ Return $ str
*/
Function getMonthDay ($ year, $ month, $ day, $ format = 'Y-m-d', $ last = 0 ){
If ($ last ){
$ Time = new DateTime ($ day );
$ D = strtotime ($ time-> format ("Y-m-d "));
$ D = date ("t", $ d );
$ Time-> setDate ($ year, $ month, $ d );
} Else {
$ Time = new DateTime ();
$ Time-> setDate ($ year, $ month, $ day );
}
Return $ time-> format ($ format );
}
If you want to obtain the first day of June 1, getMonthDay (, 1), return: March 2013
If you want to obtain the last day of January 1, getMonthDay (, '', 1 ),
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB