简体   繁体   中英

time Update of avatar image

because I have a image upload system for each user so that each user has their own profile picture, and hey it simply been controlling when you change an image the user must wait at least three minutes to return to change the image, in principle it works well I miss eh

if (  $tiempo >= $row['HoraAvatar']  || $row['HoraAvatar'] == "NULL" ) { 
    return true;             
} 
else { 
    return false; 
} 

$time -> This variable contains the current time (24 hour format) $row ['HoraAvatar'] -> Time in which change by the image last time (24h format)

sensilla compared this works well ... but the problem is that when the user changes his image at 12:59 PM and wants to switch to the 9:00 am fails, because would be comparing

$time = 900;
$row ['HoraAvatar'] = 1259;

the condition $time> = $row ['HoraAvatar']: to return FALSE

Use a timestamp instead. A timestamp is the amount of seconds since a fixed point in time. If a user wants to change his image exactly 24 hours after the last time, your "HoraAvatar" would be exactly the same. A timestamp would be exactly 86400 bigger than your previous timestamp. You can do this with the time() function in php. ( docs )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM