Re: getting $date



Graham Gough <graham@xxxxxxxxxxxx> wrote in comp.lang.perl.misc:
> #!/usr/bin/perl
>
> use strict;
> my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
>
> $year += 1900;
> $mon++;
>
> my $date = "$mday/$mon/$year";
>
> print $date, "\n";

Alternatively:

use POSIX;
print POSIX::strftime '%d%m%y', localtime;

Anno
.



Relevant Pages

  • Re: how to execute two commands?
    ... > Hi Anno, ... Not only to Perl, but also to Usenet, it seems. ... Use localtime() to get the date. ... To see the documentation for localtime, ...
    (comp.lang.perl.misc)
  • Re: strftime format in win32 Perl
    ... ActiveState Perl 5.8.4: ... print strftime($format, localtime), "\n"; ... The format "%r" is not work. ... The documentation of strftime in "perldoc POSIX" says ...
    (comp.lang.perl.misc)
  • Re: Dates again.
    ... Rafael Morales wrote: ... > use POSIX qw; ... tell localtime to use a date 72 days ago, ... localtimetakes a Unix timestamp as an ...
    (perl.beginners)
  • Re: Time format
    ... Jm lists wrote: ... 'localtime') Thanks. ... use POSIX 'strftime'; ... Perl isn't a toolbox, but a small machine shop where you can special-order ...
    (perl.beginners)
  • Re: strftime format in win32 Perl
    ... I am trying to execute this peace of code in WindowsXP using ... ActiveState Perl 5.8.4: ... use POSIX 'strftime'; ... print strftime($format, localtime), "\n"; ...
    (comp.lang.perl.misc)