Gossamer Forum
Home : Products : Gossamer Forum : Discussion :

How to add a global var of "Today's new post numbers"

Quote Reply
How to add a global var of "Today's new post numbers"
Please show me the code. That can help me know how many posts added to my forum today.

Last edited by:

backdream: Sep 10, 2002, 9:03 PM
Quote Reply
Re: [backdream] How to add a global var of "Today's new post numbers" In reply to
Hi,

Try:

Code:
sub {
my @now = localtime;
my $today = GT::Date::timelocal(0, 0, 0, $now[3], $now[4], $now[5]);
my $cond = GT::SQL::Condition->new(
'post_time', '>=', ', $today
);
my $count = $DB->table('Post')->count( $cond );
return $count;
}


The tricky part is figuring out the unix time for midnight today. If you want all posts in the last 24 hours, that's a lot easier. This isn't tested but should work.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] How to add a global var of "Today's new post numbers" In reply to
God bless you ...

but

my $cond = GT::SQL::Condition->new(
'post_time', '>=', ', $today
);


maybe some mistake,I change it to

my $cond = GT::SQL::Condition->new(
post_time => '>=' => $today
);


It works good.

Last edited by:

backdream: Sep 11, 2002, 5:21 PM