Jump to content

Can anyone figure out what is wrong?


djfox

Recommended Posts

Ok, first, here is the code:

 

<?php
$checkhour = strftime("%H", time());

if ($checkhour == 00) {
$dayname = "Evening";
$daynum = "2";
}
elseif ($checkhour == 01) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 02) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 03) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 04) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 05) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 06) {
$dayname = "Morning";
$daynum = "4";
}
elseif ($checkhour == 07) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 08) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 09) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 10) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 11) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 12) {
$dayname = "Evening";
$daynum = "2";
}
elseif ($checkhour == 13) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 14) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 15) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 16) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 17) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 18) {
$dayname = "Morning";
$daynum = "4";
}
elseif ($checkhour == 19) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 20) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 21) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 22) {
$dayname = "Day";
$daynum = "1";
}
elseif ($checkhour == 23) {
$dayname = "Day";
$daynum = "1";
}
?>

 

Here is what the code should do:

Figure out what hour the time is and declare if the time is day/night/morning/evening depending on what the hour is.

 

What the problem is:

It seems to have a problem with hour 08. All the other hour times work but that one. And by work I mean it will echo $dayname. With hour 08, it echos nothing.

 

EDIT:

Anyone know what happened to the "Topic Solved" tab? Past few posts of mine I cannot find that to mark my topics solved.

Link to comment
Share on other sites

I`ve tried this code:

 

<?php
if ($checkhour == 00 || $checkhour == 12) {
$dayname = "Evening";
$daynum = "2";
}
elseif ($checkhour == 01 || $checkhour == 02 || $checkhour == 03 || $checkhour == 04 || $checkhour == 05 || $checkhour == 13 || $checkhour == 14 || $checkhour == 15 || $checkhour == 16 || $checkhour == 17) {
$dayname = "Night";
$daynum = "3";
}
elseif ($checkhour == 06 || $checkhour == 18) {
$dayname = "Morning";
$daynum = "4";
}
elseif ($checkhour == 07 || $checkhour == 08 || $checkhour == 09 || $checkhour == 10 || $checkhour == 11 || $checkhour == 19 || $checkhour == 20 || $checkhour == 21 || $checkhour == 22 || $checkhour == 23) {
$dayname = "Day";
$daynum = "1";
}
?>

 

But it still will not work for hour 08.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.