What you need is 3 Date objects:
<script type="text/javascript">
<!--
var curDt = new Date ();
// Year is set to 2000 no matter what (hack) so this will work for all
years.
curDt.setUTCFullYear (2000);
var earlyDt = new Date ("January 1, 2000 07:42:00");
var lateDt = new Date ("January 1, 2000 09:06:00");
// Check to see if within range. When 2 Date objects are subtracted, the
result is the difference in milliseconds.
if (((curDt - earlyDt) >= 0) && (curDt - lateDt) <= 0)) {
document.write ('Happy New Year');
} else {
document.write (' ');
}
Documentation for the Date object is found at
http://devguru.com/technologies/javascript/10585.asp
This is a good reference resource. It starts at
http://devguru.com/technologies/javascript/home.asp
--Tim Sabin
spylogic3 wrote:
> I'm just a beginner, so bear with me.
>
> I am experimenting and trying to figure out what conditions I need
> (for the "if" statement) to make it display "Happy New Year" from 7:42
> am to 9:06 am.
>
> If it was just 7 am to 9 am, I could do it, but I don't know how to do
> it with the minutes.
>
> The code so far:
>
> ==============
>
> <script type="text/javascript">
> <!--
> var d = new Date()
> var h = d.getHours()
> var m = d.getMinutes()
>
> // display Happy New Year from 7:42 am to 9:06 am
> if ( ???? )
> document.write('Happy New Year')
>
> //if not, display nothing
> else document.write(' ')
>
> //-->
> </script>
>
>
>
> ------------------------------------
>
> Visit http://aiaiai.com for more groups to joinYahoo! Groups Links
>
>
>
>
>