Nov 2, 2001, 2:47 AM
Post #2 of 2
I don't know what kind of database U use.
Is it a flat-text-file, or MySQL, and what do you mean with 'an image inserted' in the database. Is that a filename or what else?
About the date.
In the perldoc there are many answers for your question.
However, you stored your date in a very difficult format to compare it. You need to take care or leapyears, long and short months (maybe DST times) etc to determine what is actually 7 days ago.
In perl you have the time() function. They return the current time in seconds from epoch. Just store that value in your database. That value can be passed through localtime() or gmtime() to get a time string.
# constants for localtime() array
use constant SEC => 0;
use constant MIN => 1;
use constant HOUR => 2;
use constant MDAY => 3;
use constant MON => 4;
use constant YEAR => 5;
use constant WDAY =>6;
use constant YDAY => 7;
use constant DST => 8;
my $Time = time(); # current time
my $SevenDays = (60 * 60 * 24 * 7); # in seconds
my $Earlier = $Time - $SevenDays;
my $TimeStr = localtime($Earlier);
print "Seven days earlier: $TimeStr\n";
my @Time = localtime($Earlier);