【问题标题】:Get last month and current month record of user in codeigniter active record在codeigniter活动记录中获取用户上个月和当前月份的记录
【发布时间】:2016-02-25 06:23:41
【问题描述】:

我们要获取上个月用户积分的记录。 我们有用户创建日期前。 25-08-2015。 第二张表是用户积分。

但主要是:-

如果当前日期是 23-11-2015

我们想要点表之间的记录:-

上个月:25-09-2015 至 25-10-2015

当前月份:25-10-2015 至 25-11-2015

如果当前日期是 28-11-2015

我们想要在点表中的 redcord:-

上个月:25-10-2015 至 25-11-2015

当前月份:25-11-2015 至 25-12-2015

注意:表示用户创建日期是用户月份的开始日期和用户月份的结束日期

【问题讨论】:

  • 不管是什么日期,你要从25号取到25号??

标签: php mysql codeigniter date


【解决方案1】:

您可以执行以下操作:

function get_day_for_date($date)
{
     $day = date('d', strtotime($date));
     return $day;
}

$user_reg = "25-08-2015";

$current_month_start = get_day_for_date($user_reg) ."-". date("m-Y",    strtotime("-1 months"));
$current_month_end = get_day_for_date($user_reg) ."-". date("m-Y");

$last_month_start = get_day_for_date($user_reg) ."-". date("m-Y",  strtotime("-2 months"));
$last_month_end = get_day_for_date($user_reg) ."-". date("m-Y", strtotime("-1 month"));

//echo $current_month_start . ", ". $current_month_end;
//echo "<br>";
//echo $last_month_start . ", ". $last_month_end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-10
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 2020-07-21
    相关资源
    最近更新 更多