Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to find number of days between current timestamp and login date [duplicate]

Tags:

php

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

like image 339
maham Avatar asked Dec 20 '22 22:12

maham


1 Answers

 $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));
like image 188
Dan Barzilay Avatar answered May 04 '23 08:05

Dan Barzilay