webguy262 Posted July 1, 2010 Share Posted July 1, 2010 I need an if statement that works like this... if the datetime in the database is less than a year earlier than the current date account is good; else your account has expired. I suspect it is something like... if (curtime() - $datetime_in_dbase <= 365 days) { ok } else { not ok } Can't seem to find exactly how to code it. Suggestions? Link to comment https://forums.phpfreaks.com/topic/206449-if-datetime-within-a-year-of-current-time/ Share on other sites More sharing options...
rwwd Posted July 1, 2010 Share Posted July 1, 2010 You could do what you stated just making sure that the format of date/time matches whats in the DB so: if((date("y m d") - $datetime_in_dbase) <= 365 days){ //good }else{ //bad } pseudo code there obviously Rw Link to comment https://forums.phpfreaks.com/topic/206449-if-datetime-within-a-year-of-current-time/#findComment-1079964 Share on other sites More sharing options...
Mchl Posted July 1, 2010 Share Posted July 1, 2010 In MySQL SELECT IF(dateTimeColumn > CURDATE() - INTERVAL 1 YEAR,TRUE,FALSE) AS accountValid FROM ... Link to comment https://forums.phpfreaks.com/topic/206449-if-datetime-within-a-year-of-current-time/#findComment-1079967 Share on other sites More sharing options...
webguy262 Posted July 2, 2010 Author Share Posted July 2, 2010 thanks for the replies! I'll try them and post back. Link to comment https://forums.phpfreaks.com/topic/206449-if-datetime-within-a-year-of-current-time/#findComment-1080291 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.