对于这个问题,很可能会有重复,但我很难为我的问题找到一个精确的答案.
用户输入客户租金的开始日期(在前一页的表格上),然后需要生成客户需要支付的下一个日期(一周后).例如:
$start_date = $_POST['start_date'];
$date_to_pay = ???
Run Code Online (Sandbox Code Playgroud)
让我们说用户在2015/03/02进入:
$start_date = "2015/03/02";
Run Code Online (Sandbox Code Playgroud)
然后,我希望支付的日期等于一周后(2015/03/09):
$date_to_pay = "2015/03/09";
Run Code Online (Sandbox Code Playgroud)
怎么会这样做呢?非常感谢.
我正在构建一个嵌入式项目,显示从显示器上的GPS模块检索的时间,但我还想显示当前日期.我目前有时间作为unix时间戳,而progject是用C语言编写的.
我正在寻找一种从时间戳计算当前UTC日期的方法,考虑到闰年?请记住,这是针对没有FPU的嵌入式项目,因此模拟浮点数学,尽可能避免性能.
编辑
在看了@R ...的代码之后,我决定自己写一篇文章并提出以下内容.
void calcDate(struct tm *tm)
{
uint32_t seconds, minutes, hours, days, year, month;
uint32_t dayOfWeek;
seconds = gpsGetEpoch();
/* calculate minutes */
minutes = seconds / 60;
seconds -= minutes * 60;
/* calculate hours */
hours = minutes / 60;
minutes -= hours * 60;
/* calculate days */
days = hours / 24;
hours -= days * 24;
/* Unix time starts in 1970 on a Thursday */
year = 1970;
dayOfWeek = 4; …Run Code Online (Sandbox Code Playgroud)