Jump to content

[SOLVED] simple date problem


acidglitter

Recommended Posts

edit:

 

I tried it with the date you gave me.

 

I never tried anything like this before, so i randomly made my own script, and seems like it worked

 

<?php
$now  = time();
$date = mktime(0,0,0,12,18,2007);

$now = explode("-",date("y-m-d",$now));
$then = explode("-",date("y-m-d",$date));

$year = $now[0] - $then[0];
$month = $now[1] - $then[1];
$days = $then [2] - $now[2]; 
echo "Years left: ".$year;
echo "<br>";
echo "Months left: ".$month;
echo "<br>";
echo "Days left: ".$days;
?>

 

 

Link to comment
Share on other sites

You could also do it in SQL....

 

mysql> SELECT DATEDIFF('2007-12-25', CURDATE());

+-----------------------------------+

| DATEDIFF('2007-12-25', CURDATE()) |

+-----------------------------------+

|                                 9 |

+-----------------------------------+

1 row in set (0.00 sec)

 

 

Meaning, you could probably do something like:

 

SELECT DATEDIFF(DATE(in_the_future_column), CURDATE()) as days_until

 

 

Edit: Manual link: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_curdate

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.