Question : A Perl Date module problem

Hi,

I can retrieve todays date using Date::Calc module. Can you pls help as to how I can retrieve todays hour mins and secs time using the same module in another variable say $cob_date1?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
use Date::Calc qw(:all);


sub _getCOB {

my $mon = 'JanFebMarAprMayJunJulAugSepOctNovDec';

my @date;

my ($year,$month,$day) = Add_Delta_Days(Today(),0);


my $dow = Day_of_Week($year,$month,$day);

#if($dow == 1) {
#  @date = Add_Delta_Days(Today(), -3);
# }

#elsif ($dow == 7) {
#  @date = Add_Delta_Days(Today(), -2);
#  }


  @date = Add_Delta_Days(Today(), -0);


my $date = $date[2] . '-' . substr($mon, $date[1]*3 - 3, 3) . '-' . $date[0];

return $date;
}


my $cob_date;

$cob_date = &_getCOB();

print $cob_date;

Answer : A Perl Date module problem

To simplify and expand on what you have, you can do this...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
use Date::Calc qw(:all);

my @mon = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);

sub _getCOB {

    my @date = Today();

    # commented out since not used
    #my $dow = Day_of_Week(@date);

    my $date = $date[2] . '-' . $mon[$date[1]] . '-' . $date[0];

    return $date;
}


my $cob_date = &_getCOB();
my $cob_date1 = join ':', Now();

print $cob_date, "\t", $cob_date1, "\n";
Random Solutions  
 
programming4us programming4us