|
-
Apr 21st, 2006, 06:37 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] PHP DateDiff()
please can anyone help me on how to check the difference(in days) between two dates.
say like checking the day difference between yesterday and today.
PHP Code:
function date_diff($date1, $date2){
//i'm stuck here...
//some code please...
return $diff
}
thanks in advance
Last edited by modpluz; Apr 21st, 2006 at 06:41 AM.
-
Apr 21st, 2006, 06:39 AM
#2
Re: PHP DateDiff()
Since you have PHP in the thread title, I'm assuming that is the language you are using. If not, PM me and I will move it to the appropriate forum.
Moved from the CodeBank
-
Apr 21st, 2006, 06:42 AM
#3
Thread Starter
Fanatic Member
-
Apr 21st, 2006, 06:44 AM
#4
Thread Starter
Fanatic Member
Re: PHP DateDiff()
oh..i'm sorry thought i was posting in the right forum.
thanks Hack
-
Apr 21st, 2006, 07:27 AM
#5
<?="Moderator"?>
Re: PHP DateDiff()
Found this in the comments in the PHP docs.
 Originally Posted by http://uk2.php.net/manual/en/function.date.php
I needed to calculate the difference between two dates in days based on current date and a date from the DB.
This will be used to check if a members subscription has lapsed ( i.e 365 days have passed ).
Here's the (simple) code:
PHP Code:
//calculate the difference between two dates in days.
$regDate=strtotime("July 15, 2005"); //will come from DB
$curDate=mktime(); //current UNIX timestamp.
$diff= $curDate - $regDate; //date diff in seconds
$diff = $diff / 86400; //date diff in days
echo $diff; //will be used to check member subscription
hope it helps someone.
-
Apr 28th, 2006, 06:15 PM
#6
Thread Starter
Fanatic Member
Re: PHP DateDiff()
thanks but i found another script that checks date difference in months, years, days, weeks and more. though, i have to modify it to suit my needs.
thanks anyway much appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|