You are here: Re: Simple PHP that isn't working « All PHP « IT news, forums, messages
Re: Simple PHP that isn't working

Posted by plato on 10/13/43 11:27

"Marc" <mbradshaw@beasolutions.com> wrote in message
news:1127385450.9943.0@lotis.uk.clara.net...
> I've got the following PHP which is designed to display a greeting
> message (client's request, not my idea), but for some reason, it is
> displaying Afternoon, any time after 12 (ie. until midnight), does
> anyone have any ideas why?
>
> Thanks in advance,
>
> Marc
>
>
> --- PHP ---
> if (date ("G") < 12) {
> $timeOfDay = "Morning";
> } elseif (date ("G") < 18) {
> $timeOfDay = "Afternoon";
> } elseif (date ("G") < 24) {
> $timeOfDay = "Evening";
> } else {
> $timeOfDay = "Day";
> }
>
> $dateToday = date ("l jS F Y");
>
> --- HTML/PHP ---
> <p>Good <?= $timeOfDay ?>. Today is <?= $dateToday ?>.</p>

Try this:

--- PHP ---
if (date ("G") < 12) {
$timeOfDay = "Morning";
} elseif (date ("G") < 18) {
$timeOfDay = "Afternoon";
} else {
$timeOfDay = "Evening";


$dateToday = date ("l jS F Y");

--- HTML/PHP ---
<p>Good <?= $timeOfDay ?>. Today is <?= $dateToday ?>.</p>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация