Display Date Dependant Content   
 
Displaying content depending on what the current date value is a powerful and effective tool that adds value to any website. Whether it is to showcase a limited time offer, or to “automatically” update pages with new content while you’re miles away. The following code repeats the process to three times to demonstrate the full effects of date dependent content. The content is set to display only on 12/31/1999 and shows a preview and how many days until the content will show up and an after view after expiration.

<% 
' The following for next loop is used to demonstrate
' how this code will work on three different dates
' The varible the_date should be set to date() to retrieve 
' the current date when implemented 
for count = 1 to 3
if count = 1 then 
the_date=#12/30/1999#
end if
if count = 2 then 
the_date=#12/31/1999#
end if
if count = 3 then 
the_date=#01/01/2000#
end if
start_date= #12/31/1999#
expiration_date = #01/01/2000#

%>




<%= "Start Date=" & start_date &" End Date=" & expiration_date & " Today=" & the_date
%>
<br>

<% if start_date <= the_date then %> 


<% 
if expiration_date - the_date <= 0 then 
%>


Content has expired <u>on</u> <%= expiration_date %>

<%
else
%>


Content will appear <u>for</u> <%= expiration_date - the_date %> more day(s)

<%
end if
%> 

<% 
else
%> 
Content will appear <u>in</u> <%= abs(the_date - start_date) %>  more day(s)

<%
end if
next
%>
The Result is something like: 

Start Date=12/31/99 End Date=1/1/00 Today=12/30/99
Content will appear in 1 more day(s)

 

Start Date=12/31/99 End Date=1/1/00 Today=12/31/99
Content will appear for 1 more day(s)

 

Start Date=12/31/99 End Date=1/1/00 Today=1/1/00
Content has expired on 1/1/00

 



My3C's
perrychicker
It's easy... it's a PSACAKE!
Back | Tell A Friend | Search this Site
© 1998 - 2008 psacake.com
Version 3.23

Send me One Million FREE Guaranteed Visitors