On 9/21/06, <b class="gmail_sendername">Patrick R. Michaud</b> &lt;<a href="mailto:pmichaud@pobox.com">pmichaud@pobox.com</a>&gt; 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>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Hi all,<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;Why doesn't this work:<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;$blogposttime = 'strftime(&quot;%H&quot;, $page[&quot;ctime&quot;])';<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;if ($blogposttime == &quot;22&quot;) $FmtPV['$BlogTimeOfDay'] = &quot;It was getting
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;late&quot;;<br>&gt;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;When I try using {$BlogTimeOfDay} in a page, nothing is returned.&nbsp;&nbsp;All I<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;want to do is have the time of day displayed not in numeric fashion, but<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;using a custom message corresponding to the time of day.&nbsp;&nbsp;Perhaps I
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;misunderstood strftime?&nbsp;&nbsp;Or I have something mixed up?<br><br><br>Surely you mean something like:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;$blogposthour = strftime('%H', $page['ctime']);<br>&nbsp;&nbsp;&nbsp;&nbsp;if ($blogposthour == '22') $FmtPV['$BlogTimeOfDay'] = &quot;'It was getting late'&quot;;
<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>&nbsp;&nbsp; $BlogPostHours = array(7 =&gt; 'It was early', 22 =&gt; 'It was getting late');
<br><br>&nbsp;&nbsp; $FmtPV['$BlogTimeOfDay'] =<br>&nbsp;&nbsp;&nbsp;&nbsp;'$GLOBALS[&quot;BlogPostHours&quot;][strftime(&quot;%H&quot;, $page[&quot;ctime&quot;])]';<br><br>Pm<br></blockquote></div><br>Awesome, thanks.&nbsp; Unfortunately because %H produces two-digit strings, I had to use array('07' =&gt; 'it was too early'), etc., but this worked.&nbsp; 
<br><br>Jon