SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast Misery's Avatar
    Join Date
    Aug 2003
    Location
    England
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How would i do an if statement for current time to display something?

    Ok title may not make much sense but here goes.
    I want to make text display between 6 and 8 pm, how would i make an if statement or whatever do that?
    <---Noob


  2. #2
    SitePoint Addict shad0w's Avatar
    Join Date
    Aug 2003
    Location
    PA
    Posts
    239
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This isn't the exact code but you could try something like if current time is less than 8 pm and greater than 6 pm, echo this. I'll try to give you the code later.

    EDIT: It can also be done easily using javascript.
    Last edited by shad0w; Oct 12, 2003 at 10:07.

  3. #3
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this.
    PHP Code:
    $h date('H');
    if ((
    $h => 18) and ($h <= 20)) { echo 'It\'s time!'; } 


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •