【问题标题】:php code for enter data when first day of month [duplicate]每月第一天输入数据的php代码[重复]
【发布时间】:2013-12-05 08:54:29
【问题描述】:

我有在 php 中输入当月最后一天的数据的功能,但是我怎样才能更改为每月的第一天。这是每月最后一天的代码。

<?php 
$a_date= date("Y-m-d");
$last_date= date("Y-m-t", strtotime($a_date)); 
if($a_date==$last_date){ }else{ } 
?>

【问题讨论】:

  • 我建议的代码是一个月的第一天
  • @DainisAbols 在这里我在每月的最后一天运行代码,但我希望该函数在每月的第一天运行。请帮帮我

标签: php


【解决方案1】:

每月的第一天: date('Y-m-01');

当月的最后一天: date('Y-m-t');

【讨论】:

  • 谢谢亲爱的,它工作得很好
【解决方案2】:
$a_date= date("j");
$last_date= date("t");
if($a_date==$last_date){ 
    // Last day of the month.
} elseif (date("j") == 1 {
    // First day of the month.
} else {
    // None of the above apply.
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-28
    • 2018-07-31
    • 2012-02-24
    • 2020-10-02
    • 2016-08-30
    • 2020-01-11
    • 2021-05-25
    • 1970-01-01
    相关资源
    最近更新 更多