Date::Format(3)
π Date::Format(3) β the User Contributed Perl Documentation glow-up π
okay so bestie, welcome to the page for Date::Format, living in the User Contributed Perl Documentation section. It's a whole module for formatting dates into ASCII strings, and it's lowkey iconic. β¨
πΈ NAME πΈ
Date::Format β date formating subroutines. (That spelling is the page's, not a typo from me, iykyk. π
)
π¦ SYNOPSIS π¦
use Date::Format;
@lt = localtime(time);
print time2str($template, time);
print strftime($template, @lt);
print time2str($template, time, $zone);
print strftime($template, @lt, $zone);
print ctime(time);
print asctime(@lt);
print ctime(time, $zone);
print asctime(@lt, $zone);
β¨ DESCRIPTION β¨
This module provides routines to format dates into ASCII strings. They correspond to the C library routines strftime and ctime. ποΈπ«
time2str(TEMPLATE, TIME [, ZONE])βtime2strconvertsTIMEinto an ASCII string using the conversion specification given inTEMPLATE. IfZONEis given, it specifies the zone the output is required to be in.ZONEdefaults to your current zone. πstrftime(TEMPLATE, TIME [, ZONE])βstrftimeis similar totime2str, except the time is passed as an array, such as the array returned bylocaltime. π°οΈctime(TIME [, ZONE])βctimecallstime2strwith the given arguments using the conversion specification"%a %b %e %T %Y\n". πasctime(TIME [, ZONE])βasctimecallstime2strwith the given arguments using the conversion specification"%a %b %e %T %Y\n". π
π MULTI-LANGUAGE SUPPORT π
Date::Format is capable of formating into several languages by creating a language specific object and calling methods, see Date::Language. π£οΈ
my $lang = Date::Language->new('German');
$lang->time2str("%a %b %e %T %Y\n", time);
The author says: "I am open to suggestions on this." ππ«Ά
π CONVERSION SPECIFICATION π
Each conversion specification is replaced by appropriate characters as described in the following list. The appropriate characters are determined by the LC_TIME category of the program's locale. ποΈ
%%β PERCENT%aβ day of the week abbr%Aβ day of the week%bβ month abbr%Bβ month%cβMM/DD/YY HH:MM:SS%Cβ ctime format:Sat Nov 19 21:05:57 1994%dβ numeric day of the month, with leading zeros (eg01..31)%eβ like%d, but a leading zero is replaced by a space (eg 1..32)%DβMM/DD/YY%Gβ GPS week number (weeks since January 6, 1980)%hβ month abbr%Hβ hour, 24 hour clock, leading 0's)%Iβ hour, 12 hour clock, leading 0's)%jβ day of the year%kβ hour%lβ hour, 12 hour clock%Lβ month number, starting with 1%mβ month number, starting with 01%Mβ minute, leading 0's%nβ NEWLINE%oβ ornate day of month --"1st","2nd","25th", etc.%pβ AM or PM%Pβ am or pm (Yes%pand%Pare backwards :)%qβ Quarter number, starting with 1%rβ time format:09:05:57 PM%Rβ time format:21:05%sβ seconds since the Epoch, UCT%Sβ seconds, leading 0's%tβ TAB%Tβ time format:21:05:57%Uβ week number, Sunday as first day of week%wβ day of the week, numerically, Sunday == 0%Wβ week number, Monday as first day of week%xβ date format:11/19/94%Xβ time format:21:05:57%yβ year (2 digits)%Yβ year (4 digits)%Zβ timezone in ascii. eg:PST%zβ timezone in format-/+0000
Also: %d, %e, %H, %I, %j, %k, %l, %m, %M, %q, %y and %Y can be output in Roman numerals by prefixing the letter with O, e.g. %OY will output the year as roman numerals. ποΈβ¨
π LIMITATION π
The functions in this module are limited to the time range that can be represented by the time_t data type, i.e. 1901-12-13 20:45:53 GMT to 2038-01-19 03:14:07 GMT. π That's the range, periodt.
π AUTHOR π
Graham Barr <gbarr@pobox.com> π«Ά
π«Ά COPYRIGHT π«Ά
Copyright (c) 1995-2009 Graham Barr. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. π
π cute footer sign-off: perl v5.42.0, dated 2020-05-20, page Date::Format(3) β that's a wrap, bestie! ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-TimeDate 2.33-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms