User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,989 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,217 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 364 | Replies: 2
Reply
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 522
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Compare date of database with current date

  #1  
Jul 3rd, 2008
Hello..

I want to compare my database date with current system date and i can do some oprations by that..

Wating ...

Shanti
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Posts: 19
Reputation: ditty is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 1
ditty ditty is offline Offline
Newbie Poster

Re: Compare date of database with current date

  #2  
Jul 3rd, 2008
hi....

I think you can use the following function to compare two dates.

function dateDiff($dformat, $endDate, $beginDate)
{
$date_parts1=explode($dformat, $beginDate);
$date_parts2=explode($dformat, $endDate);
$start_date=gregoriantojd($date_parts1[0], $date_parts1[1], $date_parts1[2]);
$end_date=gregoriantojd($date_parts2[0], $date_parts2[1], $date_parts2[2]);
return $end_date - $start_date;
}

calling function is
$dformat shows the special character used to seperate date,month and year. it can be "-","/",etc.
$dateCmp=dateDiff("-",$date2,$date1);

Actually this function will return the number of days between $date1 and $date2. if the returned value is 0 then the two dates are equal. if it is greater than 0 then $date2 is greater than $date1 and so on.

Only one thing u have to notice is the date should be in MM-DD-YY format. For this you can use explode() function.
Reply With Quote  
Join Date: Jul 2008
Location: Hyderabad,India.
Posts: 522
Reputation: Shanti Chepuru is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 53
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Posting Pro

Re: Compare date of database with current date

  #3  
Jul 3rd, 2008
Thank you DITTYY for your quick response...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 9:45 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC