-   Programming (
-   -   php date compare (

omarswan 10-02-2002 05:51 AM

php date 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.


function can_post($lastPost, $now) {

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


Marty_Mandrake 10-02-2002 07:34 AM

If both dates are in a unix time stamp form then, you can do this.

PHP Code:

function can_post($lastPost$now) {
$seconds_in_a_day 24*60*60;
$seconds_since_last_post $now $lastPost;
     If (
$seconds_since_last_post $seconds_in_a_day) {
     } else {

This function will return a value of 0 if the person cannot post and a function of one if they can.

omarswan 10-02-2002 05:41 PM

Thanks Marty
Thanks Marty

All times are GMT -5. The time now is 01:16 PM.