I am implemening simple file-sharing service. Currently I use a file-based database (as it suits my needs).
# somewhere in my cgi script
sub first_run
{
my $dbh = DBI->connect('dbi:DBM:');
$dbh = DBI->connect("dbi:DBM:", "", "",{ AutoCommit => 1, RaiseError => 1, f_dir=>$DATABASE_DIR} );
unless ($dbh)
{
print "<br>Cannot connect: $DBI::errstr";
return undef;
}
$dbh->do("CREATE TABLE uploads( user_name TEXT,
file_name TEXT,
upload_date TEXT ) ");
$dbh->disconnect( );
}
As you can see I propose to store the upload timestamp as a string, since currently I only have to display it (suppose to use localtime() to get timestamp in a human readable format). But this seems to me somewhat bad. What if later I'll want to show uploads from some period, etc.
What is the common way of storing timestamps in a DBM database without using third-party, CPAN modules? How can I pull them later and show them to the user (in my situation, convert back to string)?