202 lines
6.1 KiB
HTML
202 lines
6.1 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of Date::Format</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>Date::Format</H1>
|
|
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-03-06<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
Date::Format - Date formating subroutines
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
|
|
|
|
|
|
|
|
<PRE>
|
|
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);
|
|
|
|
</PRE>
|
|
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
|
|
|
|
This module provides routines to format dates into <FONT SIZE="-1">ASCII</FONT> strings. They
|
|
correspond to the C library routines <TT>"strftime"</TT> and <TT>"ctime"</TT>.
|
|
<DL COMPACT>
|
|
<DT id="1">time2str(<FONT SIZE="-1">TEMPLATE, TIME</FONT> [, <FONT SIZE="-1">ZONE</FONT>])<DD>
|
|
|
|
|
|
<TT>"time2str"</TT> converts <TT>"TIME"</TT> into an <FONT SIZE="-1">ASCII</FONT> string using the conversion
|
|
specification given in <TT>"TEMPLATE"</TT>. <TT>"ZONE"</TT> if given specifies the zone
|
|
which the output is required to be in, <TT>"ZONE"</TT> defaults to your current zone.
|
|
<DT id="2">strftime(<FONT SIZE="-1">TEMPLATE, TIME</FONT> [, <FONT SIZE="-1">ZONE</FONT>])<DD>
|
|
|
|
|
|
<TT>"strftime"</TT> is similar to <TT>"time2str"</TT> with the exception that the time is
|
|
passed as an array, such as the array returned by <TT>"localtime"</TT>.
|
|
<DT id="3">ctime(<FONT SIZE="-1">TIME</FONT> [, <FONT SIZE="-1">ZONE</FONT>])<DD>
|
|
|
|
|
|
<TT>"ctime"</TT> calls <TT>"time2str"</TT> with the given arguments using the
|
|
conversion specification <TT>"%a %b %e %T %Y\n"</TT>
|
|
<DT id="4">asctime(<FONT SIZE="-1">TIME</FONT> [, <FONT SIZE="-1">ZONE</FONT>])<DD>
|
|
|
|
|
|
<TT>"asctime"</TT> calls <TT>"time2str"</TT> with the given arguments using the
|
|
conversion specification <TT>"%a %b %e %T %Y\n"</TT>
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>MULTI-LANGUAGE SUPPORT</H2>
|
|
|
|
|
|
|
|
Date::Format is capable of formating into several languages by creating
|
|
a language specific object and calling methods, see Date::Language
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
my $lang = Date::Language->new('German');
|
|
$lang->time2str("%a %b %e %T %Y\n", time);
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
I am open to suggestions on this.
|
|
<A NAME="lbAF"> </A>
|
|
<H2>CONVERSION SPECIFICATION</H2>
|
|
|
|
|
|
|
|
Each conversion specification is replaced by appropriate
|
|
characters as described in the following list. The
|
|
appropriate characters are determined by the <FONT SIZE="-1">LC_TIME</FONT>
|
|
category of the program's locale.
|
|
<P>
|
|
|
|
|
|
|
|
<PRE>
|
|
%% 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 (eg 01..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 %p and %P are 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
|
|
|
|
</PRE>
|
|
|
|
|
|
<P>
|
|
|
|
<TT>%d</TT>, <TT>%e</TT>, <TT>%H</TT>, <TT>%I</TT>, <TT>%j</TT>, <TT>%k</TT>, <TT>%l</TT>, <TT>%m</TT>, <TT>%M</TT>, <TT>%q</TT>,
|
|
<TT>%y</TT> and <TT>%Y</TT> can be output in Roman numerals by prefixing the letter
|
|
with <TT>"O"</TT>, e.g. <TT>%OY</TT> will output the year as roman numerals.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>LIMITATION</H2>
|
|
|
|
|
|
|
|
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 <FONT SIZE="-1">GMT</FONT> to
|
|
2038-01-19 03:14:07 <FONT SIZE="-1">GMT.</FONT>
|
|
<A NAME="lbAH"> </A>
|
|
<H2>AUTHOR</H2>
|
|
|
|
|
|
|
|
Graham Barr <<A HREF="mailto:gbarr@pobox.com">gbarr@pobox.com</A>>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>COPYRIGHT</H2>
|
|
|
|
|
|
|
|
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.
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="5"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="6"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="7"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="8"><A HREF="#lbAE">MULTI-LANGUAGE SUPPORT</A><DD>
|
|
<DT id="9"><A HREF="#lbAF">CONVERSION SPECIFICATION</A><DD>
|
|
<DT id="10"><A HREF="#lbAG">LIMITATION</A><DD>
|
|
<DT id="11"><A HREF="#lbAH">AUTHOR</A><DD>
|
|
<DT id="12"><A HREF="#lbAI">COPYRIGHT</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:38 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|