Answer the question
In order to leave comments, you need to log in
How to convert date?
<?php
function days_in_month($year, $month) {
return round((mktime(0, 0, 0, $month+1, 1, $year) - mktime(0, 0, 0, $month, 1, $year)) / 86400);
}
$days_in_mon = days_in_month(2017, 06);
//var_dump($days_in_mon);
//die;
for($day = 1; $day <= $days_in_mon; $day++){
$day."<br>";
}
?>
$day."<br>";
how to fix
Answer the question
In order to leave comments, you need to log in
function getPeriod($year, $month)
{
$date = (new DateTimeImmutable())->setDate($year, $month, 1);
$interval = new DateInterval('P1D');
return new DatePeriod($date, $interval, $date->modify('+1 month'));
}
$period = getPeriod(2017, 6);
foreach ($period as $date) {
// формат можете указать любой
echo $date->format('d:m:Y') . '<br>';
}
date_format()
Well, or a crutch:$str_day = ($day <10) ? "0".$day : $day;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question