When writing Perl scripts I frequently find the need to obtain the current time represented as a string formatted as YYYY-mm-dd HH:MM:SS (say 2009-11-29 14:28
YYYY-mm-dd HH:MM:SS
2009-11-29 14:28
Try this:
use POSIX qw/strftime/; print strftime('%Y-%m-%d',localtime);
the strftime method does the job effectively for me. Very simple and efficient.
strftime