I'm basically trying to replace this:
my $sth=$dbh->prepare(
"SELECT DATE_FORMAT(NOW(), '%M %D, %Y')");
my $rv=$sth->execute;
my ($date) = $sth->fetchrow_array; $sth->finish;
with something that doesn't call the database. it seems a bit silly that this code is:
- in a loop
- the statement isn't prepared outside of the loop
- hits the database multiple times for a date when perl could do it
- could at least be prepare_cached
so i started looking at POSIX::strftime. only thing is, i can't find a modifier that will add the ordinal suffix to the day of the month. i've read through the
perldoc for POSIX.pm, i've read
man strftime ... i've even done some googling ... nothing.
the database query returns: October 22nd, 2004
what i thought would be the equiv. POSIX compliant format
use POSIX qw( strftime );
my $date = strftime "%B %d, %Y", localtime;
returns: October 22, 2004
can i accomplish the 'suffixing' of the ordinal with the POSIX formats, or should I just handle the date outside of the loop?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.