Setting a time limit using strftime?

I’m trying to make a timelimit in my script.

A record is set into my dbtable using NOW() and datetime. Now I want this record to be editable the next 48 hours but after that timelimit it should be locked…

This is what I want to do:

$currDate = strftime('%Y-%m-%d %H:%I:%S');
$tableDate = strftime($row['date']);

if(// If date is within the 48 hours limit do something here //){

} else { 
   // If date is passed the timelimit //
}

Can somebody please help me with this, please…

Thanks in advance :slight_smile:

i’m not sure exactly what $row[‘date’] contains. if it is just a date then it’s not possible to accurately do 48 hours from when the record is set because the time info is missing.

let’s assume you can get a timestamp value of when the update was made somehow, say into $updated_ts, then:


$updated_ts = .....

if( (time() - $updated_ts) <= (2*24*60*60) ) {
	// If date is within the 48 hours limit
} else {
	// If date is passed the timelimit
}

Its a datetime field ( 2011-01-25 15:55:13)

Does that help?

yup:
$updated_ts = strtotime($row[‘date’]);