PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Save your reputation with your customers. Learn how you can have embedding success with Advantage Database Server (ADS).
  #1  
Old October 2nd, 2002, 05:22 AM
omar omar is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 18 omar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question php date & time compare

Hi guys,
I'm working on a web project using php which has an
application form, and I need some help with
comparing dates.

Let's assume that I already have a function that
get the last date and time a user of a specific
ip address made a post. I basically want to limit
a user (based on their ip) to one (1) post
per day (24 hrs) or once every two days.

I just need help in creating a function
that can compare the two dates.

example

function can_post($lastPost, $now) {
'...
}

It would also be nice if I could tell when
is the next time that the can post.

thanks!

Reply With Quote
  #2  
Old October 2nd, 2002, 10:42 AM
laidbak laidbak is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Location: In Tha IE -- San Bernardino COUNTY
Posts: 788 laidbak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 4 m 2 sec
Reputation Power: 6
Send a message via ICQ to laidbak Send a message via AIM to laidbak Send a message via MSN to laidbak Send a message via Yahoo to laidbak
Try something like this:

<?
/* Last post was October 1, 2002 @ 5:10AM */
// mktime is as follows (hour, minute, second, month, day, year)
$lastpost = mktime(5,15,0,10,1,2002);

echo 'Last Post was: ', date("M-d-Y H:m:s a", $lastpost), '<br>';

if (canPost($lastpost, 24)) {
echo 'The time now is: ', date("M-d-Y H:m:s a", time()), '<br>';
print 'ok to post';
} else {
echo 'next post time is ', date("M-d-Y H:m:s a", $lastpost+(3600*24));
}


function canPost($lastpost, $diff)
{

// Lets turn hours into seconds
$diff = $diff*3600;

// When can the user post next?
$nextpost = $lastpost+$diff;

// What time is it now?
$timenow = time();


// Is the time now greater than the
// next available post time?
if ($timenow > $nextpost) {
return true;
} else {
return false;
}

}


?>

Reply With Quote
  #3  
Old October 2nd, 2002, 04:08 PM
omar omar is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 18 omar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks I'll give it a try

Thanks I'll give it a try

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > php date & time compare


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five &quot;checkpoints&quot; for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Iron Speed




© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway