On Mon, 2007-08-13 at 15:44 +0800, lena wrote:
> Ow,
>
> Although the previous program works. There is a typo, "$d should be
> $date". corrected version below:
>
> #!/usr/bin/perl
>
> require "timelocal.pl";
>
> sub rdxtime
> {
> my ( $date ) = @_ ;
> my @t = split(/[-:\s]/,$date);
> $t[0] -= 1900; $t[1] -= 1; # check manpage of localtime
> @t = reverse(@t);
> return timelocal(@t);
> }
>
> $d = "2007-08-13 14:39:48";
>
> print rdxtime ($d);
>
Thanks Man.. BTW, what is timelocal.pl?
Anyway.. I finally relented and just subcumed to using local bash and
backticks.
this 1 liner got me what I wanted. (kinda surprising that a solution
using perl was that complicated)
$epoch_base_datetime=`date -d \"$start_date\" +%s`;
start_date -> 2007-07-31 12:00:00
epoch_base_datetime -> 1185854400
_______________________________________________
Slugnet mailing list
[email protected]
http://www.lugs.org.sg/mailman/listinfo/slugnet