To get all dates in given month and year, we need to know how many days in that given month and year.
to do that we are going to use PHP's date() and mktime() functions.
Syntax :
date(format,timestamp)
mktime(hour,minute,second,month,day,year,is_dst);
Function:
the following function will return dates in array format for given month and year in Y-m-d format.
Parameters:
usage:
Example:
output:
Explanation:
We just calculated the number of days in month and using for loop, we are creating array in our own format.
Have any doubt, feel free to comment here!
to do that we are going to use PHP's date() and mktime() functions.
Syntax :
date(format,timestamp)
mktime(hour,minute,second,month,day,year,is_dst);
Function:
the following function will return dates in array format for given month and year in Y-m-d format.
Parameters:
$month - Month number
$year - Year
usage:
$dates = get_dates($month,$year);
Example:
output:
Explanation:
We just calculated the number of days in month and using for loop, we are creating array in our own format.
Have any doubt, feel free to comment here!
0 comments:
Post a Comment