# Solved: Conditional DIV Display by Time and Date



## drfresh (Jul 17, 2010)

Hi, I'm doing a product launch and I was wondering how to have a div display only from ... this date, this time to this date, this time..

I found a thread here, but there are fill in the blanks that I can't really work with haha..


```
<?php
if (time() < mktime(12, 0, 0, 9, 9, 2007))
    echo 'some div blah, blah, blah';
?>
```
That's the code that answered the question, but I guess I need someone to spell it out for me.. I'm just used to copying and pasting codes and editing.

I think even if I did have a working code I'd have to have something in my html to link to it? or have the code inside of my html? not sure..

So I've got a page with a sales video and I want it to only display a button under it when my counter hits 0..

Blah anyways,

Any amount of help is appreciated..


----------



## drfresh (Jul 17, 2010)

anybody???? I'll pay $5 paypal to whoever can get me on the right track.. lol


----------



## ehymel (Aug 12, 2007)

Perhaps no one is answering because it's not really clear what you are asking... what does a counter hitting 0 have to do with a date? Perhaps you could post a link for us to look at with a SPECIFIC question about what you are wanting, and leave off the "blah blah blah" and "haha" stuff. If the code sample you posted is helpful, you might try going to the documentation pages on php.net for some help, like http://us.php.net/manual/en/function.mktime.php


----------



## drfresh (Jul 17, 2010)

Sorry for not being clear..

I need a div to display on a specific date - and on that date only.

The countdown timer has nothing to do with it but that the div will be in sync with it when it hits zero (which will be at the specified date at 12 AM EST). The div's code will be independent of the timer.

So I also want it to consider the date that it displays the div be based on EST.. 

Around the world it will display at the exact same time, regardless if it's not that date in their timezone.

Thanks if you decide to help..

EDIT: I think it'd have to be javascript so the div will display without having to refresh the page. I may still use php and just put "refresh the page when the timer hits zero" or something...


----------



## ehymel (Aug 12, 2007)

Great! Now that's very clear. The answer is quite straightforward.

Since php runs on the server, then your php script will "know" what time it is local to your server (unless you explicitly tell it something different). Therefore you have no need to worry about where clients from around the world connect from. If you want some content within a div tag to appear on or after a certain date, let's say March 1, 2011, then just insert something like this into your page:


```
<?php if (time() >= strtotime('March 1, 2011')) { ?>
 div stuff, buttons, links, or whatever 
<?php } ?>
```


----------



## drfresh (Jul 17, 2010)

Awesome, thanks man.

I tried to use it but it shows "= strtotime('July 18, 2010')) { ?>" above the div when i tested it, so is there a certain way to insert it into html? or should I create a separate php file and reference to it in the html somehow?


----------



## ehymel (Aug 12, 2007)

It looks like your server is not interpreting the php code as php.

Make sure you have php installed and running, and make sure your script is named so that it ends in .php, as in page.php (as opposed to something like page.htm).


----------



## drfresh (Jul 17, 2010)

SWEET.. I made a separate php file and iframed it into the main html.. and it's workin good.

Thanks again man, much appreciated


----------



## ehymel (Aug 12, 2007)

OK, iframe seems like overkill, but glad it works.

Make sure to mark this thread as solved...


----------

