XSSI Library

Show Per Date or Time
Developed by Ross Olson

With this piece of XSSI, you can tell your page to display a certain section of HTML, before, during, or after a certain date.

The basic concept is to take the current date (or time) and turn it into a numeric variable that can be compared mathematically to a number that you design.

This technique shown below can be extended to be based on any of the timefmt codes that are number-based. With this you can use any of the standard mathematical comparison symbols including:

  • = (equals, equivalent : during)
  • > (greater than : after)
  • < (less than : before)
  • >= (greater than or equal to : after and during)
  • <= (less than or equal to : before and during)

Note that for hours, you should use the %H command so you don't have to use AM and PM. Note also that when you make your timefmt command be careful to not have any spaces between the commands. And finally, be sure to use the full four digit version of the year until we get past the year 2000.

<!--#config timefmt="%Y%m%d" -->

<!--#if expr="$DATE_LOCAL < 19980917" -->

<P>This will be shown before my birthday in 1998
<!--#endif -->

<!--#if expr="$DATE_LOCAL >= 19980917" -->

<P>This will be shown during and after my birthday in 1998
<!--#endif -->

<!--#if expr="$DATE_LOCAL = 19990101" -->

<P>This will be shown during New Year's Day, 1999. (Happy New Year!)
<!--#endif -->

<!--#if expr="$DATE_LOCAL >= 19981120" -->

<!--#if expr="$DATE_LOCAL <= 19990101" -->
<P>This will be shown during the US year-end holiday season, 1998. (Happy Holidays!)
<!--#endif -->
<!--#endif -->

Ross Olson

   

A printer-friendly version of this article is available.
This site hand-coded for your protection.