On May 13, Harry Putnam said:

>Is there a date manipulation module that does the same thing as gnu
>`date -d' command?  That is, given a spec string, it returns a date in
>the past in user selected format.
>
>Like what gnu `date' would do with:
>  date  -d '-2 weeks' +"%m%d%Y_%T"
>  04292004_13:20:28

You can use the standard (i.e. comes with Perl) POSIX module.  It has a
strftime() function that behaves like C's does.  Read the man page for
strftime and you'll have a pretty good idea how to use POSIX::strftime().

  use POSIX 'strftime';

  my $date = strftime "format string", localtime;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
CPAN ID: PINYAN    [Need a programmer?  If you like my work, let me know.]
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to