Jump to content

Archived

This topic is now archived and is closed to further replies.

digitalgod

displaying results from a certain date till now

Recommended Posts

hey guys,

I was wondering how can I display something from a database from a certain date till now.

Share this post


Link to post
Share on other sites
<?
$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";

}
?>

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.