Last active
October 30, 2022 15:39
-
-
Save Jayaramki/8f71e55cdc65cbe34d76 to your computer and use it in GitHub Desktop.
Get All Dates in given month and year in php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*Get All Dates in given month and year in php by CJ Ramki (http://cj-ramki.blogspot.in)*/ | |
function get_dates($month,$year){ | |
$numbers = array('1','2','3','4','5','6','7','8','9'); | |
$datesArray = array(); | |
$num_of_days = date('t',mktime (0,0,0,$month,1,$year)); | |
for( $i=1; $i<= $num_of_days; $i++) { | |
if(in_array($i,$numbers)) $i = '0'.$i; | |
//complete date in Y-m-d format | |
$datesArray[]= $moYe[1] . "-". $moYe[0]. "-". $i; | |
} | |
return $datesArray; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$datesArray[]= $month . "-". $year. "-". $i;