Jump to content

Archived

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

adyre

PHP date difference

Recommended Posts

I have something like this:

<?
$sql = mysql_query("SELECT data, DATE_SUB(data, INTERVAL 20 DAY) - CUR_DATE() as DATAX");
while($row = mysql_fetch_array($sql)){
print $row['datax'];
}
?>

And it displays somethink like 90 days even if 'data' is the current date......

If any of you can help, please do that.....

Or any other method so I can display how many days remaining until "data" its 20 days old.

I delete them automaticaly if they reach 20 days, but I can't post "X days remaining"...

Excuse my English, but I'm from Romania...

Share this post


Link to post
Share on other sites
[code]SELECT (20 - (TO_DAYS(CURDATE()) - TO_DAYS(data))) AS datax[/code]

or

[code]SELECT (TO_DAYS(data) + 20 - TO_DAYS(CURDATE()) ) AS datax[/code]

Share this post


Link to post
Share on other sites
It works perfect... Thanks very much... You don't even know how much you helped me... I've tried so much to figure this out and I haven't found a solutin... 10x

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.