strftime#

Format a broken-down time as a string using a format template.

תקציר#

use POSIX qw(strftime);
my @tm = localtime;
my $str = strftime("%Y-%m-%d %H:%M:%S", @tm);

מה מוחזר#

A byte string formatted according to the template. Argument order matches localtime / gmtime: second, minute, hour, mday, mon (0-11), year (years since 1900), wday, yday, isdst - the last three optional and defaulting to -1.

מקרי קצה#

  • Fewer than seven arguments (format plus the first six tm fields): returns the empty string.

  • Output truncated at 1024 bytes.

  • Month is 0-11 and year is years-since-1900, the struct tm convention, not the 1-12 / 4-digit-year human convention.

הבדלים מן ה-upstream#

Fully compatible with upstream POSIX.

ראו גם#

  • mktime - go the other way: broken-down time → epoch seconds.

  • asctime, ctime - simpler canned-format alternatives.