Solved

date/time comparison

Posted on 2007-03-28
2
229 Views
Last Modified: 2008-02-01
Hello.  I have a situation in flash 8 where i need my movie to show different things based on the time of day it is.  like from 12 AM to 3:59:59 PM i need it to show some things and from 4 PM to 11:59:59 PM i need it to show other things.  Can someone provide some AS that will get something like this done?  i realize it's based off of the users system time.  i'm not really concerned about the year/month/day.  just the hours, minutes and seconds of whatever day.

thanks!
0
Comment
Question by:linuxrox
2 Comments
 
LVL 2

Accepted Solution

by:
khoama earned 250 total points
ID: 18809199
var dDate:Date =new Date();

//get the current Date
dDate.getDate();

// 0 <= hh <=23
hh=dDate.getHours();

// 0 <= mm <=60
mm=dDate.getMinutes()

// 0 <= ss <=60
ss=dDate.getSeconds();

//do smthing here the time here
0
 
LVL 3

Assisted Solution

by:ieciep
ieciep earned 250 total points
ID: 18815181
the following code shows how you can compare time.

Hours value ranges from 0 - 23. Lemme know if you need the source file.

code info:
-----------
timeDisp is a movie clip symbol instance.

code:
------

var myDate:Date =new Date();
date=myDate.getDate();
hours=myDate.getHours();
mins=myDate.getMinutes();
secs=myDate.getSeconds();

if(hours>=6&&hours<16)//day
{
      timeDisp.gotoAndStop(1);
}
else if(hours>=16&&hours<20)//evening
{
      timeDisp.gotoAndStop(2);
}
else if(hours>=20&&hours<6)//night
{
      timeDisp.gotoAndStop(3);
}

Regards,
Riz
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question