Gossamer Forum
Home : General : Perl Programming :

Re: [Andy] Convert yyyy-mm-dd format into UNIX timestamp...

Quote Reply
Re: [Andy] Convert yyyy-mm-dd format into UNIX timestamp... In reply to
Do you mean unixtime or timestamp?

You can't simply convert a date to unixtime by changing the format string since it needs to be converted into the seconds that have passed after 1970. This function will do the conversion:

Code:
sub {
my $year = 2005;
my $month = 9;
my $day = 21;

use Time::Local;
my $time = timelocal(0,0,0,$day,$month,$year);
return $time;
}
Subject Author Views Date
Thread Convert yyyy-mm-dd format into UNIX timestamp... Andy 14165 Sep 21, 2005, 3:23 AM
Thread Re: [Andy] Convert yyyy-mm-dd format into UNIX timestamp...
Volker 13981 Sep 21, 2005, 4:54 AM
Thread Re: [Volker] Convert yyyy-mm-dd format into UNIX timestamp...
Volker 13947 Sep 22, 2005, 2:47 AM
Post Re: [Volker] Convert yyyy-mm-dd format into UNIX timestamp...
Andy 13971 Sep 24, 2005, 12:50 AM