Clinton Canarias
Clinton Canarias

Reputation: 509

Set Condition using timespan Codeigniter

Hello I want to set condition that once the post is already posted 30mins up will not able to edit or customize.

My timespan codes:

<?php 
$post_date = $threads['created_at'];
$now = time();
echo timespan($post_date, $now, 1). '&nbsp'.lang_key('ago') ?>

I want to have a condition something like this:

Note this code is a sample only.

<?php if(timespan >= '30 mins'){
//disable the edit button
}else{
//enable the edit button
} ?>

Upvotes: 1

Views: 53

Answers (1)

Alex
Alex

Reputation: 9265

Assuming a well formed timestamp you can do:

    if (strtotime($threads['created_at']) < strtotime("-30 minutes")) {
        echo ' is older than 30 mins';
    } else {
        echo ' is not older than 30 mins';
    }

Upvotes: 1

Related Questions