www.webdeveloper.com
Results 1 to 6 of 6

Thread: Days left...

  1. #1
    Join Date
    Jan 2008
    Posts
    25

    Days left...

    I'm running a website and I need a simple way to have an item show for example, "Day's left (# number of days left)" and automatically change after each day. Can it be done with HTML?

  2. #2
    Join Date
    Aug 2007
    Location
    New Jersey, US
    Posts
    1,779

  3. #3
    Join Date
    Jan 2008
    Posts
    25
    Quote Originally Posted by dtm32236
    That's what I'm afraid of. I need to be able to display it in a message board post like this one and scripts aren't allowed.

  4. #4
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    you could use a server side language and have it change an image...

  5. #5
    Join Date
    Jan 2008
    Posts
    25
    Quote Originally Posted by scragar
    you could use a server side language and have it change an image...
    So you mean like image rotation?

  6. #6
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    very similar idea, here's a PHP version:
    PHP Code:
    <?
    // set header.
    header ("Content-type: image/png");

    // get time string.
    $theTime strtotime("10 September 2008"); // set your date of choice.
    $now strtotime("now");
    $timeLeft $theTime $now;
    $days floor($timeLeft/60/60/24);
    if(
    $days){
        
    $theText = ($days==1)?"1 day left":$days " Day(s) left";
    }else{
        
    $theText "You've missed it";
    };
    // create image.
    $im = @imagecreatetruecolor(12020) or die("Cannot create new image");

    // assign colours, using rgb.
    $white imagecolorallocate($im255255255);
    $black imagecolorallocate($im000);
    // fill image and add text.
    imagefill($im11$white);
    imagestring($im155,  $theText$black);

    // show image.
    imagepng($im);
    // destroy image to save memory.
    imagedestroy($im);
    ?>
    shouldn't be too hard to make versions in other languages.

    you can see this in action here
    Last edited by scragar; 01-07-2008 at 09:33 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles