4

Possible Duplicate:
How to calculate the difference between two dates using PHP?
How to find number of days between two dates using php
How to find the dates between two specified date?

i have three fields in my table

 seeker
 name ....current_time.... login_date

second field i have created through timestamp phpmyadmin
type: timestamp
default: current_timestamp

when seeker get registered his current_time automatically inserted by timestamp

 third field is login_date filed. when user logins then this field is updated 

//login date
$login_date = date("Y-m-d");
echo "login date"."".$login_date;
$qry1 = "update seeker set login_date = '$login_date' where name='$uname'";
$res1=mysql_query($qry1,$con);

now current_date is like 
"2012-04-10 21:58:01"

and login_date is like
"2012-05-02"

i want to find number of days between these two dates. i dont know how to subtract these dates because current_date includes time too.. or is there any other way to exclude time from current-date i-e it enters only date not time

2
  • I think I got the wrong link... :D But it's very related :) Commented May 2, 2012 at 17:05
  • the problem is about the timestamp.. in above mentioned link there are only date not time.. Commented May 2, 2012 at 17:07

1 Answer 1

11
 $login_date = strtotime(x); // change x with your login date var
 $current_date = strtotime(y); // change y with your current date var
 $datediff = $current_date - $login_date;
 $days = floor($datediff/(60*60*24));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.