uksza has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks
I need sometimes in my litte scripts date/time in nice format. I can use (on Linux machines):
Second pure Perl, but a little to long...
Third is almost OK, but is it good idea to use POSIX in 20 lines scripts?
In QandASection: dates and times I can't found nothing else
How do you do this in your's programs?
greetz, Uksza
Yes, smart people know that fat arrow autoquotes the left argument. But why should you require your code to be maintained by smart people? Randal L. Schwartz, Perl hacker
I need sometimes in my litte scripts date/time in nice format. I can use (on Linux machines):
ormy $date = `date +%Y-%m-%d_%H:%M`; chomp $data;
ormy ( $ss, $mm, $hh, $mday, $mon, $year, $wday, $yday, $isdst ) = localtime(); my $data = sprintf( "%d-%02d-%02d %02d:%02d", ( $year += 1900, $mon += 1, $mday, $hh, $mm ) );
First is little and nice, but use external program.use POSIX 'strftime'; my $date = strftime '%x %X.', localtime;
Second pure Perl, but a little to long...
Third is almost OK, but is it good idea to use POSIX in 20 lines scripts?
In QandASection: dates and times I can't found nothing else
How do you do this in your's programs?
greetz, Uksza
Yes, smart people know that fat arrow autoquotes the left argument. But why should you require your code to be maintained by smart people? Randal L. Schwartz, Perl hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to get quick i nice date format?
by demerphq (Chancellor) on Feb 08, 2006 at 10:47 UTC | |
Re: How to get quick i nice date format?
by holli (Abbot) on Feb 08, 2006 at 12:08 UTC | |
Re: How to get quick i nice date format?
by davis (Vicar) on Feb 08, 2006 at 10:36 UTC | |
Re: How to get quick i nice date format?
by mickeyn (Priest) on Feb 08, 2006 at 15:30 UTC |
Back to
Seekers of Perl Wisdom