fry2010 Posted February 26, 2009 Share Posted February 26, 2009 I need to compare todays date with a mysql date that is already in a table. So : if( todays_date_in_php > expire_date_set_in_table) return true; The mysql date is set as '0000-00-00' format, but I cant work out how to convert that to php format and compare them. any pointers or solutions appreciated. Link to comment https://forums.phpfreaks.com/topic/146965-solved-compare-php-date-with-mysql-date/ Share on other sites More sharing options...
premiso Posted February 26, 2009 Share Posted February 26, 2009 Why not compare it in mysql? You can use strtotime to convert the date in mysql to unix timestamp and compare it, alternatively you can use date to format the date to mysql format date('Y-m-d') Link to comment https://forums.phpfreaks.com/topic/146965-solved-compare-php-date-with-mysql-date/#findComment-771519 Share on other sites More sharing options...
fry2010 Posted February 26, 2009 Author Share Posted February 26, 2009 thanks a lot. I didnt think of maybe reversing it, but that seems easier. Im not very familiar with date stuff, its the one thing that really elludes me. Link to comment https://forums.phpfreaks.com/topic/146965-solved-compare-php-date-with-mysql-date/#findComment-771533 Share on other sites More sharing options...
premiso Posted February 26, 2009 Share Posted February 26, 2009 Yea, it is confusing. However, the problem with unix timestamps is that they have a limitation of 2038, vs the mysql datetime does not. Just so you know, if trying to go past that date you will get issues using time stamps. Link to comment https://forums.phpfreaks.com/topic/146965-solved-compare-php-date-with-mysql-date/#findComment-771534 Share on other sites More sharing options...
fry2010 Posted February 26, 2009 Author Share Posted February 26, 2009 cool, noted. Thanks again. Works like a charm. Link to comment https://forums.phpfreaks.com/topic/146965-solved-compare-php-date-with-mysql-date/#findComment-771622 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.