Skip to content

Instantly share code, notes, and snippets.

@Jayaramki
Last active October 30, 2022 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Jayaramki/8f71e55cdc65cbe34d76 to your computer and use it in GitHub Desktop.
Save Jayaramki/8f71e55cdc65cbe34d76 to your computer and use it in GitHub Desktop.
Get All Dates in given month and year in php
/*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;
}
@joejoe123312
Copy link

what is that $moYe? undefined variable

@lgeorgiev
Copy link

what is that $moYe? undefined variable

$datesArray[]= $month . "-". $year. "-". $i;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment