dpv46227 2014-04-17 05:17
浏览 8

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

When a user creates an account I have to manually activate some of its functionality (which I want). What I need to happen after its activation is take $someTIMEvar (days, min, seconds any will work) till the end of the month UPDATE/SET a DB entry. Then use $newTIMEvar (the DB entry) in an equation. After the end of the month this process dose not need to happen again.. any suggestions?

EDIT -- Ill try to be more clear. using my code

<?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;
?>

How do I get it to only happen once.. then at the end of the month not happen again.. ?

  • 写回答

1条回答 默认 最新

  • duanlu9970 2014-04-17 06:20
    关注

    Use a setting in database for the month after that you dont want to run that part of code. So that you can check like

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

    Or If you don't have any problem in hard coding than you can put the month in your code like :

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

报告相同问题?

悬赏问题

  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算