On 9/21/06, <b class="gmail_sendername">Patrick R. Michaud</b> <<a href="mailto:pmichaud@pobox.com">pmichaud@pobox.com</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Thu, Sep 21, 2006 at 09:13:03AM -0500, Jon Haupt wrote:<br>> Hi all,<br>><br>> Why doesn't this work:<br>><br>> $blogposttime = 'strftime("%H", $page["ctime"])';<br>> if ($blogposttime == "22") $FmtPV['$BlogTimeOfDay'] = "It was getting
<br>> late";<br>><br>> When I try using {$BlogTimeOfDay} in a page, nothing is returned. All I<br>> want to do is have the time of day displayed not in numeric fashion, but<br>> using a custom message corresponding to the time of day. Perhaps I
<br>> misunderstood strftime? Or I have something mixed up?<br><br><br>Surely you mean something like:<br><br> $blogposthour = strftime('%H', $page['ctime']);<br> if ($blogposthour == '22') $FmtPV['$BlogTimeOfDay'] = "'It was getting late'";
<br><br>Note especially the single quotes inside of double quotes in the<br>$FmtPV value, because $FmtPV is called with eval().<br><br>Another way to do this might be to use a lookup array:<br><br> $BlogPostHours = array(7 => 'It was early', 22 => 'It was getting late');
<br><br> $FmtPV['$BlogTimeOfDay'] =<br> '$GLOBALS["BlogPostHours"][strftime("%H", $page["ctime"])]';<br><br>Pm<br></blockquote></div><br>Awesome, thanks. Unfortunately because %H produces two-digit strings, I had to use array('07' => 'it was too early'), etc., but this worked.
<br><br>Jon