【问题标题】:create a php that can display the date of today and the one in 6 days创建一个可以显示今天日期和 6 天内日期的 php
【发布时间】:2018-01-15 06:55:07
【问题描述】:

我有这个 php 文件:

<?php
echo "wednesday = 10 dec au 16 dec";
?>

我每个星期三手动更改它(下星期三,它将是"wednesday = 17 dec au 23 dec";)

我想为此设置一个 cron 作业,但我需要知道如何让 php 计算今天的日期(cron 作业将在每个星期三安排)和 6 天后使用我的格式有。

类似

$thisWed = date('d  M');
$nextWed_day = date("d")+6;
$nextWed_month = date("M"); 
echo "$thisWed au $nextWed_day  $nextWed_month";

(但是如果$nextWed_month 必须更改,因为$thisWed 是 29 还是 30 怎么办??)

知道如何简单地做到这一点吗?

【问题讨论】:

  • 使用date()函数,这里是图例php.net/manual/en/function.date.php
  • 谢谢。当我使用你的链接时,我已经编辑了我的帖子。但是现在,最后一个问题,如果“下星期三”更改月份,如何管理?

标签: php date cron


【解决方案1】:

关于标题: 今天 => date('d'); 还有 6 天 => date('d', strtotime('+6 days')).

关于你的正文(对不起,如果我没有理解正确):

下周三 => date('d', strtotime('next wednesday')).

来源: strtotime ref / date ref.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-06
    • 2019-04-05
    相关资源
    最近更新 更多