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
Back to
Seekers of Perl Wisdom