Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-02-2002, 04:51 AM   #1
LQ Newbie
Registered: May 2002
Location: NY, USA.
Distribution: RH + Win2k
Posts: 11

Rep: Reputation: 0
Question 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.

Old 10-02-2002, 06:34 AM   #2
LQ Newbie
Registered: Sep 2002
Location: About 12 inches from the monitor
Distribution: Mandrake 9.0
Posts: 7

Rep: Reputation: 0
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.
Old 10-02-2002, 04:41 PM   #3
LQ Newbie
Registered: May 2002
Location: NY, USA.
Distribution: RH + Win2k
Posts: 11

Original Poster
Rep: Reputation: 0
Thanks Marty

Thanks Marty


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
php read from file and compare. xushi Programming 11 07-14-2005 01:10 PM
Why do I get a broken connection when I try to compare SID with a variable (PHP 4) vharishankar Programming 6 07-09-2005 10:57 AM
compare date uusing shell programming please... izza_azhar Programming 7 01-14-2005 07:24 AM
how to compare 2 text files by using php code antony_csf Programming 3 10-14-2004 05:52 AM
PHP Calculate, Compare.. Pts Gerardoj Programming 8 05-26-2004 12:54 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:43 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration