Giri
Giri

Reputation: 4909

MySQL time difference between now() and updated time

My code looks like this

$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;
            }}

I would like to change value 6001 to 1 week. Can anyone tell me how to calculate the value for 1 week, 2 weeks and 1 month?

Upvotes: 0

Views: 277

Answers (1)

George
George

Reputation: 36794

So like this..

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

Am I in the ballpark?

Upvotes: 1

Related Questions