Jump to content

Differnce in days


DeanWhitehouse

Recommended Posts

I have this code for the difference in days , but i think i am doing something wrong as it is not returning the correct result.

 

<?php 
$today1 = $rows['started_on']; 
$today1 = date("d.m.Y",strtotime($today1)); 
$f_date1 = $rows['completed_on'];
$f_date1 = date("d.m.Y",strtotime($f_date1 )); 
$difference = intval(($f_date1 - $today1)/86400+1);  
echo $difference;
?>

 

The $rows are stored in this format (2008-08-07 21:43:10), any ideas. Note: i will need it to work out the amount of days from when i started to when i finished, that may go into another month.

Link to comment
Share on other sites

bit of a prob

this is my code

$sql = "SELECT *, (TO_DAYS(".$rows['started_on'].") - TO_DAYS(`".$rows['completed_on']."`)) as `difference`  FROM sites WHERE id = '$site_id' AND member_id = '$id'";// this is my problem, the vars need to be retireved from the db , do i need to reset the pointer if so how?
$query = mysql_query($sql);
$number = mysql_num_rows($query);
?>
<p align="center" style="text-align:left; margin-left:5px;">	
<?php
if($number == 0)
{
	echo "Either the site is not registered , or the site is not registered to this username. Please check and try again.";
}
else
{
	while($rows = mysql_fetch_assoc($query))
	{
	echo $rows['difference'];
                }
?>

Link to comment
Share on other sites

I dont think any one actually saw the comment so here it is

this is my problem, the vars need to be retireved from the db , do i need to reset the pointer if so how?

 

corresponds to this line

$sql = "SELECT *, (TO_DAYS(".$rows['started_on'].") - TO_DAYS(`".$rows['completed_on']."`)) as `difference`  FROM sites WHERE id = '$site_id' AND member_id = '$id'";

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.