English 中文(简体)
如何在目前时间序列和日志之间找到天数[复制]
原标题:how to find number of days between current timestamp and login date [duplicate]
  • 时间:2012-05-02 17:01:56
  •  标签:
  • php
This question already has answers here:
Closed 11 years ago.

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 本表有三个领域

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

second field i have created through timestamp phpmyadmin
type: timestamp
default: current_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 希望在这两个日期之间找到天数。 i 确切知道如何将这些日期细分,因为目前——日期也包括时间。 或以任何其他方式将时间排除在目前期限之外,即该时限仅于非时间日期。

最佳回答
 $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));
问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签