gpt4 book ai didi

javascript - Codeigniter-PHP : How to Change table week Dates , 更改输入日期

转载 作者:行者123 更新时间:2023-11-30 20:56:50 25 4
gpt4 key购买 nike

<input type = "date" name = "myDate" onchange = ""> //this is input date 

当用户选择一个日期然后它想根据上面的日期进行更改如何根据给定日期进行更改,请帮助我..!

<table class="table table-bordered" id="thbg">

<thead><td></td>

<th>Project</th>

<th>Activity</th>

<th>Bill Type</th>

<?php

$day = "1";
$month = "11";
$year = "2017";

$start_date = $day."-".$month."-".$year;
$start_time = strtotime($start_date);

$end_time = strtotime("+1 week", $start_time);

for($i=$start_time; $i<$end_time; $i+=86400)
{
print '<th align="center"> '. date("m-d-Y l", $i). '</th>';
}
?>
<th>Hours</th>
</thead>
</table>

并且输出也有错误的日期,例如我一次有两个星期天

this is my wrong output

谁能提出解决方案?

最佳答案

不确定您在这里尝试实现什么,但更好的选择是使用 DateTime

类似的东西应该可以工作

$day = "1";
$month = "11";
$year = "2017";
$objDateStart = DateTimeImmutable::createFromFormat('j-m-Y', $day."-".$month."-".$year);
$objDateEnd = $objDateStart->modify('+1 week');

$objDateRange = new DatePeriod($objDateStart, new DateInterval('P1D'), $objDateEnd);
foreach($objDateRange as $objDate)
{
echo '<th align="center"> '. $objDate->format("m-d-Y l"). '</th>';
}

关于javascript - Codeigniter-PHP : How to Change table week Dates , 更改输入日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47571290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com