Search the web
Sign In
New User? Sign Up
JavaScript_Official · JavaScript . AJAX . ActionScript
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
BEGINNER QUESTION: Date/Time Function   Message List  
Reply | Forward Message #16525 of 16817 |
Re: [JavaScript] BEGINNER QUESTION: Date/Time Function

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 ('&nbsp;');
}

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('&nbsp;')
>
> //-->
> </script>
>
>
>
> ------------------------------------
>
> Visit http://aiaiai.com for more groups to joinYahoo! Groups Links
>
>
>
>
>



Wed Jan 7, 2009 4:09 am

timsabin
Online Now Online Now
Send Email Send Email

Forward
Message #16525 of 16817 |
Expand Messages Author Sort by Date

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...
spylogic3
Offline Send Email
Jan 7, 2009
12:03 am

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...
Tim Sabin
timsabin
Online Now Send Email
Jan 7, 2009
4:09 am

Thanks for your ideas ... I had to set the month and day to Jan 1, too ... the...
spylogic3
Offline Send Email
Jan 8, 2009
12:59 am

I am only getting the first image to play over and over, what am I missing here? var imageSequence = new Array(); imageSequence[0] = "images/imageLoad1"; ...
ed.blinn@...
ed.blinn...
Offline Send Email
Jan 8, 2009
12:59 am

Your programming language is not JavaScript but ActionScript. I am not familiar with Flash. I guess the problem is the following code: for (var i = 0; i<12;...
comphilip@...
comphilip
Offline Send Email
Jan 8, 2009
10:04 pm

Hi Ed, Actually this is ActionScript not Javascript but I'll take a swing. There are a couple of things going on here. In the "for" loop, it looks like you...
Paul Donahue
scramjetter
Offline Send Email
Jan 8, 2009
10:05 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help