+ Reply to Thread
Results 1 to 8 of 8

Thread: Morning, afternoon, evening php help

  1. #1
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Morning, afternoon, evening php help

    I have the following code and it is supposed to tell you the "time of day" basically morning, afternoon, or evening but it keeps on poping out morning


    PHP Code:
    $date date("G");
    echo 
    $date;

    if ((
    $date) == '01' OR '02' OR '03' OR '04' OR '05' OR '06' OR '07' OR '08' OR '09' OR '10' OR '11' OR '12'){
    $time 'morning';
    }elseif(
    '13' OR '14' OR '15' OR '16' OR '17' OR '18'){
    $time 'afternoon';
    }elseif(
    '19' OR '20' OR '21' OR '22' OR '23' OR '24'){
    $time 'evening';
    }else{
    $time 'sorry';


    I would love to change the world, but they won't give me the source code

  2. #2
    Conor's Avatar
    Conor is offline Lord Of The Keys Conor is an unknown quantity at this point
    Join Date
    Jan 2005
    Location
    Toronto
    Posts
    1,785

    Re: Morning, afternoon, evening php help

    Not a PHP guru but are you sure its a 24 hour clock?

  3. #3
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Morning, afternoon, evening php help

    ya i made that mistake earlier. G is 24 with leading zero

    I would love to change the world, but they won't give me the source code

  4. #4
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Morning, afternoon, evening php help

    Why not like..

    PHP Code:
    if ($date <= 09) {
       
    $time 'morning';
    }
    elseif (
    $date >= 10) AND ($date <= 18) {
       
    $time 'afternoon';
    }
    elseif(
    $date >= 19) {
       
    $time 'evening';
    }
    else{
       
    $time 'sorry';

    I havent' tested it.. But you should get the idea.

  5. #5
    Chris S's Avatar
    Chris S is offline Retired Chris S is an unknown quantity at this point
    Join Date
    Mar 2005
    Posts
    1,036

    Re: Morning, afternoon, evening php help

    Quote Originally Posted by Bryon
    Why not like..

    PHP Code:
    if ($date <= 09) {
       
    $time 'morning';
    }
    elseif (
    $date >= 10) AND ($date <= 18) {
       
    $time 'afternoon';
    }
    elseif(
    $date >= 19) {
       
    $time 'evening';
    }
    else{
       
    $time 'sorry';

    I havent' tested it.. But you should get the idea.
    because im a noob at some types of php

    thanks, this is what worked

    PHP Code:
    if ($date <= 09) {
       
    $time 'morning';
    }
    elseif (
    $date >= 10 AND $date <= 18) {
       
    $time 'afternoon';
    }
    elseif(
    $date >= 19) {
       
    $time 'evening';
    }
    else{
       
    $time 'sorry';

    there was 1 small error
    Last edited by Chris S; 05-06-2006 at 10:55 PM.

    I would love to change the world, but they won't give me the source code

  6. #6
    Bryon is offline Administrator Bryon has disabled reputation
    Join Date
    Apr 2005
    Location
    Northfield, NH
    Posts
    7,608

    Re: Morning, afternoon, evening php help

    elseif (($date >= 10) AND ($date <= 1) {

    ;)

  7. #7
    minievan Guest

    Re: Morning, afternoon, evening php help

    Im paying someone to teach me php, and so far I only know variables and the basics XD

    Good luck if you havnt sorted it out anyway..

  8. #8
    Origin's Avatar
    Origin is offline x10 Elder Origin is an unknown quantity at this point
    Join Date
    Mar 2005
    Location
    Silicon Valley, California
    Posts
    541

    Re: Morning, afternoon, evening php help

    Why don't you play yourself to learn PHP then?


    Visit OriginXT.COM Network! It has a popular RPG, featuring a battle system, an original RPG Shop, and much more! In addition to the RPG, we also feature a community with almost a quarter million posts, hundreds of free games in the arcade, free downloads and even an instant chatroom! Just come on and join the 1500 community members in hot debates and fun; you're SURE to love it!

    My blog (Origin XT Blog), Homepage and WebClubs.org

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. [PHP] Variables in PHP
    By Bryon in forum Tutorials
    Replies: 15
    Last Post: 01-29-2009, 09:46 AM
  3. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  4. [PHP] PHP For Starters
    By Complex in forum Tutorials
    Replies: 24
    Last Post: 06-14-2008, 11:40 PM
  5. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers