1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Coding Question

Discussion in 'Off Topic' started by Chimpie, Jul 24, 2011.

  1. Chimpie

    Chimpie Well-Known Member

    I'll freely admit I have no idea how to code this, so feel free to laugh at me before responding. :)

    I want text "ABC" to show before a certain date, and text "DEF" to show up after that date.

    Thanks!
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    How is the date being generated?

    You may be able to do it with basic HTML/CSS by using spans.
     
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    raw php:

    Code:
    <?php
    
    if (time() < strtotime('2011-07-24 00:00:00'))
    {
    	echo 'ABC';
    }
    else
    {
    	echo 'DEF';
    }
    
    ?>
    
     
  4. Chimpie

    Chimpie Well-Known Member

    Thanks Jake.

    EDIT: n/m - figured it out
     
  5. Chimpie

    Chimpie Well-Known Member

    So is this correct, or should I use 'elseif' for the two middle 'if's?
    Code:
    <?php
    
    if (time() < strtotime('2011-07-24 00:00:00'))
    {
    echo 'ABC';
    }
    if (time() > strtotime('2011-07-24 00:00:01'))
    if (time() < strtotime('2011-07-26 00:00:00'))
    {
    echo 'Between';
    }
    else
    {
    echo 'DEF';
    }
    
    ?>
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Code:
    <?php
    
    if (time() < strtotime('2011-07-24 00:00:00'))
    {
    	echo 'ABC';
    }
    else if (time() < strtotime('2011-07-26 00:00:00'))
    {
    	echo 'BETWEEN';
    }
    else
    {
    	echo 'DEF';
    }
    
    ?>
    
     
  7. James

    James Well-Known Member

    You could use a switch instead of all the ifs.
     
  8. Chimpie

    Chimpie Well-Known Member

    Yeaaahh, I don't know what that is. :(
     
  9. James

    James Well-Known Member

Share This Page