可能重复:
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?
我的桌子上有三个字段
seeker
name ....current_time.... login_date
second field i have created through timestamp phpmyadmin
type: timestamp
default: current_timestamp
当导引头注册时,他的current_time由时间戳自动插入
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"
我想查找这两个日期之间的天数。我不知道如何减去这些日期,因为current_date也包括时间......或者是否还有其他方法可以从当前日期中排除时间i-e只输入日期而不是时间
答案 0 :(得分:12)
$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));