NOTICE

정해진 기간만 달력으로 나타내기

Date : 2019. 11. 18. 16:13 Category : Programming/PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<table>
    <thead>
        <tr>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
            <th></th>
        </tr>
    </thead>
    <tbody>
    <?php
    $data = $loop = [];
    $data['start_date'= "2019-10-29"// 시작일
    $data['end_date'= "2019-11-14"// 종료일
    $sdate = date("Y-m-d", strtotime((date("w", strtotime($data['start_date'])) * -1)." day", strtotime($data['start_date'])));
    $enum = 6 - date("w", strtotime($data['end_date']));
    $edate = date("Y-m-d", strtotime($enum." day", strtotime($data['end_date'])));
    for($i = 0$date < $edate$i++) {
        $date = date("Y-m-d", strtotime($sdate." +".$i."days"));
        if($i % 7 == 0echo "<tr>";
        echo "<td>".$date."</td>";
        if($i % 7 == 6echo "</tr>";
    }
    ?>
    </tbody>
</table>
cs