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
In many cases, the needed 'current time' is rather $^T, which is the time at which the script started running, in whole seconds (assuming only 60 second minutes) since the UNIX epoch.
This to prevent that an early part of a script uses a different date (or daylight-saving status) than a later part of a script, for example in query-conditions and other derived values.
For that variant of 'current time', one can use a constant, also to document that it was frozen at compile time:
use constant YMD_HMS_AT_START => POSIX::strftime( "%F %T", localtime $^T );
Alternative higher resolution startup time:
0+ [ Time::HiRes::stat("/proc/$$") ]->[10]