php - 如何查找当前时间戳和登录日期之间的天数

标签 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?

我的表中有三个字段

 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 也包含时间。或者是否有任何其他方法可以从当前日期中排除时间,即它只输入日期而不输入时间

最佳答案

 $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));

关于php - 如何查找当前时间戳和登录日期之间的天数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10418389/

相关文章:

php - 具有依赖项的子主题排队

php - 在 MySQL php 中获取最小 ID 和最大 ID 值

php - 无法在 PHP 中从 MIME 类型为 'image/x-ms-bmp' 的 BMP 创建 GD 图像资源

php - 使用数据库 onchange 中提供的 ajax 值自动计算

php - 在 php 和 mysql 中用于搜索的多个复选框?

php - 是否可以在 PHP 中弃用方法参数?

php - 如何避免 MySQL 'Unable to jump row 0' 错误?

php - 依赖下拉菜单或类似的,使用 mootools、php 和 MySQL

php - 读取具有命名空间 Simplexml 的节点

php - 代码点火器 AOP