[pmwiki-users] php/strftime question
Patrick R. Michaud
pmichaud at pobox.com
Thu Sep 21 09:35:26 CDT 2006
On Thu, Sep 21, 2006 at 09:13:03AM -0500, Jon Haupt wrote:
> Hi all,
>
> Why doesn't this work:
>
> $blogposttime = 'strftime("%H", $page["ctime"])';
> if ($blogposttime == "22") $FmtPV['$BlogTimeOfDay'] = "It was getting
> late";
>
> When I try using {$BlogTimeOfDay} in a page, nothing is returned. All I
> want to do is have the time of day displayed not in numeric fashion, but
> using a custom message corresponding to the time of day. Perhaps I
> misunderstood strftime? Or I have something mixed up?
Surely you mean something like:
$blogposthour = strftime('%H', $page['ctime']);
if ($blogposthour == '22') $FmtPV['$BlogTimeOfDay'] = "'It was getting late'";
Note especially the single quotes inside of double quotes in the
$FmtPV value, because $FmtPV is called with eval().
Another way to do this might be to use a lookup array:
$BlogPostHours = array(7 => 'It was early', 22 => 'It was getting late');
$FmtPV['$BlogTimeOfDay'] =
'$GLOBALS["BlogPostHours"][strftime("%H", $page["ctime"])]';
Pm
More information about the pmwiki-users
mailing list