如何从用户收集日期、添加天数并将答案存储为 UNIX 时间?
我有一个收集 4 条信息的表格。我的目标是根据该信息计算第五条信息(发布日期)。
- 开始日期 (YYYY-MM-DD)
- 开发天数
- QA 天数
- 发布天数
我需要对 2-4 中的整数输入求和,并将 1 中的输入相加。尽管如此,我无法使其正常工作,但我将不胜感激。
收集表单输入的代码:
$start_date = $_POST['start_date'];
$dev_days = $_POST['dev_days'];
$qa_days = $_POST['qa_days'];
$release_days = $_POST['release_days'];
计算启动日期的代码:
$start_date = strtotime($start_date);
$feature_days = $dev_days + $qa_days + $release_days;
$feature_days = $feature_days * (60*60*24);
$launch_date = strtotime($start_date, $feature_days);
I have a form that collects 4 pieces of info. My goal is to calculate a 5th piece of info (launch date) from that info.
- Start Date (YYYY-MM-DD)
- Dev days
- QA days
- Release days
I need to sum the integer input from 2-4 and add those input from 1. I can't get this to work correctly though and I would appreciate any pointers.
Code that collects form input:
$start_date = $_POST['start_date'];
$dev_days = $_POST['dev_days'];
$qa_days = $_POST['qa_days'];
$release_days = $_POST['release_days'];
Code that calculates launch date:
$start_date = strtotime($start_date);
$feature_days = $dev_days + $qa_days + $release_days;
$feature_days = $feature_days * (60*60*24);
$launch_date = strtotime($start_date, $feature_days);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要的所有内容(而不是您的 4 行)都
在您的代码中(如果您想保留“原样”并使用您自己的版本),最后一行应该是
All that you need (instead of your 4 lines) is
In your code (if you want to leave it "as is" and to use your own version) the last line should be