MySQL()和更新时间之间的MySQL时差

时间:2012-11-27 09:16:26

标签: php mysql datetime

我的代码看起来像这样

$checksql= "SELECT Body, ( NOW() - Updated ) as Age FROM ".$wpdb->prefix."amazoncache WHERE URL = '" . $keyurl . "' AND NOT( Body LIKE '%AccountLimitExceeded%') AND NOT( Body LIKE '%SignatureDoesNotMatch%') AND NOT( Body LIKE '%InvalidParameterValue%');";
        $result = $wpdb->get_results($checksql);

        if (count($result) > 0){
            if ($result[0]->Age <= 6001 && $result[0]->Body != ''){ //that would be 60 min 1 seconds on MYSQL value
                $pxml = GetXMLTree($result[0]->Body);
                return $pxml;
            }}

我想将值6001更改为1 week。谁能告诉我如何计算1 week, 2 weeks and 1 month的价值?

1 个答案:

答案 0 :(得分:1)

所以喜欢这个..

$var = 3601; // (60 * 60) + 1
$oneWeek = $var+strtotime("+1 week");
$twoWeek = $var+strtotime("+2 week");
$oneMonth = $var+strtotime("+1 month");

我在球场吗?