digitalgod Posted July 9, 2006 Share Posted July 9, 2006 hey guys,I was wondering how can I display something from a database from a certain date till now. Quote Link to comment https://forums.phpfreaks.com/topic/14079-displaying-results-from-a-certain-date-till-now/ Share on other sites More sharing options...
redarrow Posted July 9, 2006 Share Posted July 9, 2006 <?$database_date="1/1/06"; //just add the $whatever['data_basedate_here'];$date_know=date("d/m/y");if(!$database_date-$date_know){echo"hello";}else{echo"sorry wrong date";}?> Quote Link to comment https://forums.phpfreaks.com/topic/14079-displaying-results-from-a-certain-date-till-now/#findComment-55070 Share on other sites More sharing options...
ShogunWarrior Posted July 9, 2006 Share Posted July 9, 2006 I'm going to take your question as being that you want to display only rows that have a dated from x until now.To do this I'd need to know how the date is formatted. Quote Link to comment https://forums.phpfreaks.com/topic/14079-displaying-results-from-a-certain-date-till-now/#findComment-55138 Share on other sites More sharing options...
Daniel0 Posted July 9, 2006 Share Posted July 9, 2006 [code]$timestamp = 'some_unix_timestamp_here'; // replace it with a timestamp$query = mysql_query("SELECT * FROM some_table WHERE timestamp<=".time()." AND timestamp>={$timestamp}");if(mysql_num_rows($query) <= 0){ echo "No things from ".date('r')." untill now";}else { while($row = mysql_fetch_assoc($query)); { // do stuff }}[/code]In case you have it in a database where the date is stored as a UNIX timestamp, which would be the prefered way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/14079-displaying-results-from-a-certain-date-till-now/#findComment-55162 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.