Darkmatter5 Posted May 8, 2009 Share Posted May 8, 2009 I have converted a MYSQL record datetime element to a php variable via strtotime(). How can you determine if the string is today or yesterday or older then yesterday? Thanks Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/ Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 What string? strtotime() returns an int right? Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/#findComment-829816 Share on other sites More sharing options...
Darkmatter5 Posted May 8, 2009 Author Share Posted May 8, 2009 If I directly echo the array element from MYSQL it'll output "2009-05-08 11:06:49". But to answer your question I think yes, it's an int. Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/#findComment-829818 Share on other sites More sharing options...
fanfavorite Posted May 8, 2009 Share Posted May 8, 2009 Heres a simple one to get you started: $mysqldate = date('Y-m-d', $origdate); $todaysdate = date('Y-m-d'); if ($mysqldate == $todaysdate) { echo 'This is todays date'; } Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/#findComment-829822 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Or better yet, you use a query to compare that date there with CURDATE() I believe. Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/#findComment-829823 Share on other sites More sharing options...
fanfavorite Posted May 8, 2009 Share Posted May 8, 2009 Yeah, it's better to do directly with mysql, however that is not what he asked Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/#findComment-829824 Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Yeah, it's better to do directly with mysql, however that is not what he asked Then perhaps you care to clarify what it is that he asked for? Link to comment https://forums.phpfreaks.com/topic/157410-help-with-date-and-time/#findComment-829825 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.