<?xml version="1.0" encoding="windows-1252"?>
<node id="290054" title="Poor Man's strftime()" created="2003-09-09 10:37:16" updated="2005-08-08 22:05:36">
<type id="1980">
snippet</type>
<author id="272239">
liz</author>
<data>
<field name="doctext">
</field>
<field name="snippetdesc">
Some people need &lt;code&gt;strftime()&lt;/code&gt; but can't use POSIX::strftime for some reason.  This subroutine will handle most cases. Adapt, augment the conversion hash if you need more features.</field>
<field name="snippetcode">
&lt;CODE&gt;
sub strftime ($@) {
    my ($format,$second,$minute,$hour,$day,$month,$year) = @_;
    my %convert = (
     Y =&gt; $year + 1900,
     m =&gt; sprintf( '%02d',$month + 1 ),
     d =&gt; sprintf( '%02d',$day ),
     H =&gt; sprintf( '%02d',$hour ),
     M =&gt; sprintf( '%02d',$minute ),
     S =&gt; sprintf( '%02d',$second ),
    );
    $format =~ s#%(.)#$convert{$1}#sg;
    $format;
}

print strftime( '%Y%m%d.%H%M%S', localtime() );&lt;/CODE&gt;</field>
</data>
</node>
