我正在尝试创建一个方程式,使用直到月末的时间作为变量..任何建议?

时间:2014-04-17 05:17:03

标签: php mysql

当用户创建帐户时,我必须手动激活其部分功能(我想要的)。在激活之后我需要发生的是$ someTIMEvar(天,分,秒任何工作),直到月末更新/设置数据库条目。然后在等式中使用$ newTIMEvar(数据库条目)。月底之后这个过程不需要再发生..有什么建议吗?

编辑 - 我试着更清楚。使用我的代码

<?php
$end = strtotime('+1 month',strtotime(date('m').'/01/'.date('Y').' 00:00:00')) - 1; 
$now = time(); 
$numSecondsUntilEnd = $end - $now;

$num =  $dollar / $TOTAL_seconds_IN_month;//How do I get this as a function of the current month?
$new_num = $num * $numSecondsUntilEnd;
?>

我如何让它只发生一次..然后在月底不再发生..?

1 个答案:

答案 0 :(得分:0)

在您不希望运行该部分代码之后的月份中使用数据库中的设置。所以你可以检查

//if(time() < strtotime('MONTH_Setting_IN_DB 23:59:59'))

或者如果您在硬编码方面没有任何问题,可以将月份放在代码中,例如:

if(time() < strtotime('April 2014 23:59:59')) {
    // execute your code under this condition
}