Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Format Dates In Flash



Hi,

Could someone tell me how to format a date (for display as mm/dd/yy) in Flash AS3?

I've found several things for Flex... mx.formatters.DateFormatter ... but none for Flash.

Thanks for any help!
Kevin



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 12-22-2008, 02:40 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Comparing Two Dates And Return An Array With All The Dates Between
here is the problem

the user select the begin date with a DateField component and the end date with another one.

here is the code associated to the 'begin date' component

///////////////////////////////////////////////////////////
function change(eventObj_begin){
date_temp_begin = eventObj_begin.target.selectedDate;


date_begin=date_temp_begin.toString();

//take the day & month from the string
day_begin=date_begin.substring(8,10);
month_begin=date_begin.substring(4,7);

//take the year from the string
if (date_begin.length==33){
//for the days between 10 and 31
year_begin=date_begin.substring(29,33);
}else{
//for the days between 1 and 9
year_begin=date_begin.substring(28,32);
}
}
date_begin_comp.addEventListener("change", this);
///////////////////////////////////////////////////////////

the same code is used for the 'end date' component

///////////////////////////////////////////////////////////
function change(eventObj_end){
date_temp_end = eventObj_end.target.selectedDate;


date_end=date_temp_end.toString();

//take the day & month from the string
day_end=date_end.substring(8,10);
month_end=date_end.substring(4,7);

//take the year from the string
if (date_end.length==33){
//for the days between 10 and 31
year_end=date_end.substring(29,33);
}else{
//for the days between 1 and 9
year_end=date_end.substring(28,32);
}
begin=day_begin add month_begin add year_begin;

}
date_end_comp.addEventListener("change", this);
///////////////////////////////////////////////////////////

-> so I have 3 vars for the begin date :
day_begin (4) month_begin (Jan) year_begin (2005)
and 3 vars for the end date :
day_end (7) month_end (Jan) year_end (2005)

I concantenate this to have a begin var and an ending var:
//in order to have 4Jan2005
begin=day_begin+month_begin+year_begin;
//in order to have 7Jan2005
begin=day_end+month_end+year_end;


-> from this point, is it possible to have an array with all the dates between 'begin' and 'ending' ? Like
date_array=["4Jan2005","5Jan2005","6Jan2005","7Jan2005"];

List The Dates Between 2 Dates?
Hi all,

I am wondering to list the dates between two dates:

Let say, to list the dates from 2005-11-28 to 2005-12-03:

What I want to do is a function could do like this:


ActionScript Code:
listDates(2005-11-28,2005-12-03);


Then:
Output

2005-11-28
2005-11-29
2005-11-30
2005-11-31
2005-12-01
2005-12-02
2005-12-03

I first got the dates "2005-11-28" from MySQL and sent to Flash, I know I can use the Date.UTC() to convert the mySQL dates to AS format...But is there any way to do what I wanted?

Thanks very much for your help~

How Do You Convert Flash Format To Other Format?
Hi! I'm brand new to KoolMoves and I have a question. I made a banner today for a story I have posted on a website. To be able to post it on the site, I have to have it hosted through an Image Hosting website. I use Pix8, and when I tried to upload my banner to the site, it wouldn't accept the flash format. Does anyone know if there is a way to convert my banner to JPG, JPEG, GIF, BMP, PNG or PDF format? I would appreciate any help anyone could give me, this has me really frustrated! Thanks!!!

Question About Dates In Flash
okay i need a script that gets the current date. but whenever i get the date it give me the time and stuff and all i want is the month day and year...can some1 please help??

Release Dates For Flash
I'd like to find out the dates that each Flash version was released. Does anyone know where I can find that info? I thought that Colin Moock's site had that info...but couldn't find it. I searched the MM site and did a Google search, but came up with zilch.

Dates? And Time With Flash Ofcourse
Code:
time = (time1.getHours()+":"+time1.getMinutes()+":"+time1.getSeconds());
so time is a variable..ok? what actually happens is that this works alright...but lets say it shows this:
11:2:2
means 11 hours and 2 minutes and 2 seconds....
i would like to show it like this : 11:02:02
i tried adding 00 to it....put that doesnot work
in java i know there is a date format thing...but what about ActionScript? how do i do it?
secondlt i also want to show AM and PM...how does that go?

one last thing...this time is being showed with a two frame movie. if i keep this in one frame the seconds dont move on...they dont refresh...so put another frame...so the movie plays for two frames...the second frame has nothing...so each time it goes on the first frame the above script works...and the seconds tick........is this the right way?????

thanks... for all the help..

Flash Player Release Dates
Where can I find information on release dates for old versions of Flash Player?

I need to find out when version 6.0r65 was released to the public.

Thanks!

Flash Based Tour Dates - Help
We have a client that is wanting a flash map of their tour dates such as is on this site: http://www.johnmayer.com/tour

Has anyone seen something like this and could lend some expertise on the best way to build that, or is there a developer that would like to do this for compensation?

Flash 9(Blaze) Release Dates?
I am planning to buy Flash IDE in 3-4 months because I am starting to work on my own(not for a Firm I am working for now) It is better for me to buy Flash 9 at once instead of buying 8 and upgrading it to 9 after a month. So is there any approximate information on when flash 9 comes?

Valid Dates Within Flash Without Components? Possible?
Is it possible to ensure valid dates within flash without using the Date components?

I am making a form where the user defines both their date of birth and a reservation date.
Sadly, I have been told that my database spits nuts and bolts if you give it an invalid date.

Have tryed the Date component. It works well for reservations. But when it comes to Date of Birth it wouldn't work cause scrolling 20 odd years month by month would be too painful for a user.

I know its a bit of a big question. I will get someone to do it with ASP if this is too much of a nightmare in Flash.

Cheers for any help or suggestions...

Flash Player Release Dates
Does any one know when each Flash Player version, from Version 7 onwards, was released?

I tried to look on the Adobe site but could not find the relevant information.

Thanks
Alfred

Saving/comparing Dates In Flash Mysql And Php
as the title explain, i want to save and compare dates in flash and have the data stored in a mysql database, i have no idea how to go about trying to do such a thing, as i think they are different datatypes, would it be easier if i got the date variable from a php script and do the comparision there rather then doing it in flash?

what i have thus far in flash is


Code:
dateNow = new Date();
arrayDays= new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
arrayMonths= new Array('January','February','March','April','May','June','July','August','September','October','November','December');

nowDay = arrayDays[dateNow.getDay()];
nowDate = dateNow.getDate();
nowMonth = arrayMonths[dateNow.getMonth()];
nowYear = dateNow.getFullYear();
and that just brings up the date on my computer, since this is more a server side thing and i wud rather have all clients synched with the server i dont think this will work too well.

any thoughts / suggestions?

thanks in advance

XML Tour Dates In Flash Along With "click For More Details".
I have an performance artist website that I'm building. She would like tour dates to be pulled into Flash, and appear like so:


Code:
DATETIMELOCATIONDETAILS
-------------------------------------------------------------------------
9-21-20067pmyour concert hallclick for details
10-01-20068pmlocal clubclick for details
9-21-20067pmyour concert hallclick for details
9-21-20067pmyour concert hallclick for details
I've got an FLA that almost does this. But what it does is to create a single movie clip for each line, then you click that line to "view details". The problem is that FLA uses a fixed number of buttons and a isn't set up for the main list to scroll.

So I need to display the XML data along with a click for more button that simply hides the XML list and shows the details for the selected event. When the user has satisfied their curiousity, they can close the details and go back to the list.

Does anyone have something like this or have a link to a tutorial that would show me how to achieve this?

Thanks in advance.

Convert Numbers From #,# Format To #.# Format
Can anyone help me. I need to convert some input from #,# to #.# in order to perform some calcuations. There are two input boxes where the user inserts some dimension using both "," or "." decimal separators. The problem is that I can't divide a number like 4,5 only if it's written like 4.5 for example.

Thank you in advance

XML And Dates ...
Hi people,

I'm getting into the XML swing of it all, but I can't figure out this :

I have an XML file containing an ID which basically is the full year and the month (e.g. 200205 for the current month), a title and content (of course).

The title and the content work, but I want my movie to get the XML part for the current month (via the ID)

I just don't know where to begin

I know I should read out the date and month of the computer and put that together somehow ... :/

Any help is appreciated !!! mail me at info@density.nl for details when necessary !

Thanx in advance !

How Can We Sum To Dates?
Hi everyone,

I got stuck in a problem. What i need is to sum to dates.

Let say there is an event that starts at Jun 14 2007 11:30:00. The duration of the event is 50 min. That means the end time will be Jun 14 2007 12:20:00.

Now what i need is to sum the start time and the duration to get the end time.

Anyone who know how to do this please let me know. I will be very thankful.

Thanks in Advance.

Dates
Hi i Have two dynamic text boxes on stage.  This script works great to set the value of the first text box:
CODEdate2 = new Date();
    this.yearval = date2.getFullYear();
    curday = date2.getDate();
    SetMY(date2.getMonth() + 1, this.yearval);    //1 based month
    delete date2;
    ShowCal();

Between Dates
i have tried like a million things already, but i just cant get it right.

Do you guys know a good way of gettin' the milliseconds between thisDate, and a pre set date in the future.

for example the milliseconds between now and lets say midnight october 6th 2003.

Hope you guys can help me out,
any sugestions are welcome.

Thanks and greets,
fregl

Input-Dates
Hi All,
I'm new to the land of actionscript. I'm trying to write a script which will allow users to input two dates and then tell them the number of days inbetween them. Is this possible? All I can seem to get flash to do is get the system dates. I think I know a really complex way using the UTCdate fuction, but is there and easier way?
Thanks
GildoMilo

Comparing Dates
I currently have 2 variables - today (which is todays date) and expired (which is next weeks date). The text fields appear correctly as follows... today = 4/4/2002 and expired = 4/11/2002.

I am attempting to write an if statement that will go to frame 2 if today <= expired, else goto frame 3.

I am currently getting inconsistent results when changing the expired date.

How do you compare dates?

Thanks in advance!

Dates And Variables
hey again!

I was wondering if anyone might know how to script this.

I have a text field in which the user enters the date. They click a button which then checks to see if the date is formatted as such: MM/DD/YEAR.

It doesn't matter what the date is that's entered (though if I could get the date and then judged the entered date against the current date that would be cool ). The only thing that does matter right now is that the user has formatted the date like I noted above. How would I set that up?

GetSeconds Between 2 Dates **************
I would like to make something that shows the seconds that are left from time now till new years day. Is there in flash a function that i can retrieve the number of seconds from now till a specific date?
thanks

Time And Dates
Hi

How can I make a simple box which displays the time for one swf file and the date in another swf file.

I'd like to place the date on the top left and the time on the top right of my webpage.

Any suggestions?

Thanks in Advance.
Ehsan.

Hours Between Two Dates
Is it possible to use:

TargetDate = new Date(Date.UTC(2003,10,1,1));

EndDate = new Date(Date.UTC(2004,10,1,1));

To establish the number of hours in between the two dates?

M@?

Difference Between Two Dates
I am looking for a function that can return a difference between
two dates in years, months, days, and even hours and minutes like the difference may look like 4 Years, 11 Months, 16 Days, 5 Hours and 4 Minutes... Just like an opposite to count down....


Thanks in advance

Comparing Two Dates
I have two buttons one to start my process and another to finish I would like to then work out the total time it took me to complete my process but don't know how to compare the two.
Heres an aproximation of my code:

code:
btnStart.onPress = function(){
started = new Date();
}
btnFinish.onPress = function (){
finished = new Date();
totalTime = new Date (finished - started);
}


if anyone could help me with displaying the time in a text box as 09:05 instead of 9:5 that would help me aswell -

code:
startText.text = started.getHours()+":"+ started.getMinutes();

Compare Two Dates Together
hello,

i have an user inputfield for a date in the format DD.MM.YYYY

now i want to compare the date the user inserts to any other date from a variable or an array

lets say i have a date in a variable: 12.12.1986

the user insert his (any) date for example 04.03.1934...
now i want compare this two dates so the output should be

user date < date in var

i should be a flexible solution so i can use it with an array of dates an check it whit a loop if it is < or > than the inputdate

any ideas? thx

sorry for my english

greetings from austria the homecountry of ****ing "terminator" arnie blackenegger
peter

Expiry Dates
hi guys/girls, need some help if anyone can.

I need to put an expiry date in my flash movies if that is feasable.

Any ideas?

Thanks in advance

Tom

Have To Program Dates?
i havent had to deal with dates in flash yet. i know about new Date() grabbing the clock from user

are we on our own to program everything? leap-year and all that?

assume i have to use server-side scripting to get a date from the server?

[MX] Actionscript With Dates
I am trying to do a calculation where the user enters a date plus other details, a sum is performed giving the answer as a number of days (I have already succesfully done this bit) and then these days are added to the original date that was entered to give a new date. I have used various different scripts that others have put onto flashkit and I can get it to add on to the current date but not to the date the user entered.

Please help I am unable to work this out and I am going cross eyed with trying!!!!

Difference Between 2 Dates
I'm quite new to actionscript, but I know all about getDate();
getHours(); etc. But my quesion is how can I get Flash to find the difference (in days) between two dates that the user enters? For example if I have six input text boxes and I call them:

day1
month1
year1

day2
month2
year2

respectively, how can I get a dynamic text box called, say, "output" to find the difference between two dates that the user enters into the six text boxes, e.g.

day1 - The user enters 03
month1 - The user enters 09
year 1 - The user enters 2006

day2 - The user enters 25
month2 - The user enters 12
year2 - The user enters 2006

How do I get Flash to find the difference between today and Christmas? Thanks in advance.

Comparing Dates
Hey Everyone,

Just wondering if anyone has come across any tutorials for comparing dates in actionscript 2?

Basically I'm looking for a way for flash to compare a set date & time (eg 12/09/2007 12:45) with the current computer time and check if the set date is greater or less than the current computer time and play different movieclip frames for each case. (doesn't need to change dynamically - just check upon load of the movie)

Any help would be great

Thanks,
Chris

[CS3] Sort Dates
How do i perform sorting on dates?? Is a sortOn function applicable for this? i dont think so.
example, i want to sort the below sequence :


Quote:




Fri, 16 May 2008
Thu, 15 May 2008
Wed, 14 May 2008
Wed,10 Jun 2008
Mon, 12 Jul 2009




I am storing these in array:

PHP Code:



lstXml=new Array();
for (var i = 0; i<5; i++) {
            var nws = new Object();
                                      nws.nwsName= dateLst.firstChild.childNodes[i].childNodes[2].nodeValue;
            nws.nwsDate = dateLst.firstChild.childNodes[i].childNodes[3].nodeValue; // stores all the dates
            lstXml[i] = nws;
        }

Problems With Dates
GOD! When I've mastered time and date controls, I'm gonan write a biiiig walkthrough guide thingy!!

Right bare with me here:

Code:
myTime = new Date();
myMonths = myTime.getMonth();
myDays = myTime.getDate();
Thats how i've started it.
I have an animation of a tree, 366 frames long.
All I want to do is call up the date, and go to the frame!

Well someone didn't think of writing a getDayofYear function did they!?

So i took the extra long route of saying, what ever the month is, goto frame "myDays" + either of the following:


Quote:




January Day
February Day+31
March Day+60
AprilDay + 91
MayDay +121
JuneDay +152
julyDay +182
AugustDay +213
SeptemberDay +244
OctoberDay +274
november Day +304
DecemberDay +335




Long story short... it never worked!

Difference Between 2 Dates
I'm quite new to actionscript, but I know all about getDate();
getHours(); etc. But my quesion is how can I get Flash to find the difference (in days) between two dates that the user enters? For example if I have six input text boxes and I call them:

day1
month1
year1

day2
month2
year2

respectively, how can I get a dynamic text box called, say, "output" to find the difference between two dates that the user enters into the six text boxes, e.g.

day1 - The user enters 03
month1 - The user enters 09
year 1 - The user enters 2006

day2 - The user enters 25
month2 - The user enters 12
year2 - The user enters 2006

How do I get Flash to find the difference between today and Christmas? Thanks in advance.

Working With Dates
I'm trying to solve a problem in flash with dates. I've been reading, but all I can find are ways to set the "current" date (m,d,y, whatever...), but none of these functions will take a static number.

What I'm trying to do, is take a date formatted like this: 06/24/05, work some magic on it to add seven days, and return the new date - compansating for months and years if the added seven days would make the month or year move ahead. Like 06/24/05 + 7 days = 07/01/05.

Easy to do in say PHP, but hours of reading gives me nothing in AS.

Thanks for any input!!

Difference Between Dates
i need to subtract one date from another, one of which the user inputs. how can i do this in flash 8?

thanks in advance for any help!

poeli

Control MC With Dates?
Is it possible to control MC based on dates?
Im wrking on a site where the can choose among 5 characters. Each charatcer will have 5 MC. The MC will be played based on the date the visitor first entered the site. So for example if the user his/her info with a start date of 6/1/07. When they come to the site either 6/2 or after they can view the MC for 6/2 or after

The MC are supposed to play for a duration of 5 days beginning when the use first registers. Visitor cant view all MC the same day. If visitors arrives after the five days he can view all MC's

Is this a huge proj? I would be willing to pay if it requires a lot of wrk

Comparing Dates In AS
Hi,

I'm trying to do this in one line

if (date > startdate and date < enddate)

where date is what I get from a datefield and startdate and enddate I get from an XML data, and all dates are in the same format mm/dd/yyyy. Can I just do with the condition in the above if statement? Or is there some other way to do it?

Displaying Dates
Hi,

requesting someone to respond .................

I have 2 datefields say date1 and date2
Based on todays date I need to display this week dates in date1 and date2.

For Eg:

Todays date is Aug-21-2008;
Based on this
So for "this Week" I will have
date1 = Aug-17-2008 (should always be a sunday)
date2 = Aug-23-2008 (should always be a saturday)
Someone please give a logic to find date1 and date2...

AMFPHP And Dates
Hi, I am trying to send a date as part of a data packet using AMFPHP to a Flex application. I have tried used the DateWrapper but for some reason AMFPHP isn't converting it to a date object AS can use. My DTOs look like this:


PHP Code:



<?php
class dtoUser {
  /**
   * AS DTO Class
   * @var string
   */
  public $_explicitType = 'dto.User';
  /**
   * User ID Number
   * @var integer
   */
  public $id;
  /**
   * User Name
   * @var string
   */
  public $name;
  /**
   * Date of Birth
   * @var ...
   */
  public $dateOfBirth;
}
?>





ActionScript Code:
package com.icm.dto
{
  [RemoteClass(alias="dto.User")]
  [Bindable]
  public class User extends Object {
    public var id:int;
    public var name:String;
    public var dateOfBirth:Date;
    public function User(user:Object):void {
      this.id = user.id;
      this.name = user.name;
      this.dateOfBirth = user.dateOfBirth as Date;
    }
  }
}

I have tried setting the data of birth attribute in PHP using a Unix Timestamp, YYYY-MM-DD formatted date, Unix Timestamp * 1000, AMFPHP DateWrapper object as well as a PHP5 DateTime object. Can you point my in the right direction please?

Comparing Dates
Hrmm... I have searched for tutorials or posts on this and came up with squiddle, so here I go with yet another useless question:
I wish to determine the remaining days between now and a future date in Flash. Using the Date object, I know you would do something like:


Code:
trgDate = new Date(01, 10, 31);
curDate = new Date();
trgMS = trgDate.getTime();
curMS = curDate.getTime();
trace(trgMS - curMS);
What should the divisor be that trace statement to determine the number of days from milliseconds?

[Edited by 20 Ton Squirrel on 06-27-2001 at 03:26 PM]

Dates Count Down
Hi all,

I need to create a dates count down clock that will show how many dates are left to a specific event. For example, this fundrasing event will be held on June 28st, so if you look at the count down clock today it will tell you it is 31 dates away from the event.

Anywhere I can find a fla for that purpose or any turtorial? Any help appreciated. Thanks.

Help With List Of Dates...thanks
Hi,
I was hoping one of you could point me in the right direction for maybe a tutorial on the following:

I'm doing a website for a band and want to make a simple "Show Dates" section. No fancy calendars..just a list of shows. I'm not sure how to go about having only the most recent shows be visible. Like removing past shows from the list. Any suggestions? I have searched all over the forum to no avail...thanks!

Playing With Dates
how can I get this format in as3?

YYYY-MM-DD , HH:MM:SS

Here is what I have put together however it doesnt give me right day.

Code:
public function getDate(e:Event):void {

var date:Date = new Date();
var yr = date.getFullYear();
var mnth = date.getMonth()+1;
var day = date.getDay();
var hr:int = date.getHours();
var mn:int = date.getMinutes();
var time:String = hr+":"+mn;
trace(yr+"-"+mnth+"-"+day+" "+time);
Instead it gives me a single for day of week it is, How can I get the actual day number so today is the 12th 2008-5-12 for example?

Expiration Dates
Hi, I am creating a Flash Projector CD-Rom - Ok, well the client wants the CD(movie) to expire on October, 26th 2005.

Ok, i set my clock ahead, and the movie does not advance to the Scene i have designated "Expire"

Sorry, i have never coded this type of thing .... attached is the code, i have the code on the first frame of an empty scene before the login page.

Do i need an Onload ?? Is the code correct? Any help is so much appreciated !!

Thanks
Scott
Attach Code
theDate = new Date();
if (theDate.getFullYear() >= 2005) {
   if (theDate.getMonth() >= 9) {
      if (theDate.getDate() > 26) {
         gotoAndPlay("Expired");
      }
   }
}

AS3 - Dates Problem.
Hey,

I am trying to populate a combobox with 30 dates starting two weeks from todays date. Everything is cool as long as i use getTime() which includes too much information for me. When i try to format the dates month/day/year thats where the problem begins. look at the AS below.


PHP Code:



package {
    
    import fl.data.DataProvider;
    
    public class DueDates {

        public function DueDates(minDays:int) {
            
            populate(minDays);

        }
        private function populate(minDays:int):DataProvider 
        {
            var i = 0;
            var oneDay:int = (1000 * 60 * 60 * 24);
            var today:Date = new Date();
            var dateHolder:DataProvider = new DataProvider(); 
            for (i = 0; i < 30; minDays++) 
            {
var date:Date = new Date(today.getTime()+ (minDays * oneDay));
dateHolder.addItem({label:date.getMonth()+"/"+date.getDate()+"/"+ date.getFullYear(),data:i});
i++;
trace (date); 
// returns 30 dates starting from todays date... as suppose to be.
trace(date.getMonth() + "/" + date.getDate() + "/" + date.getFullYear()); 
// returns dates starting a month ago from today...
            }
            return dateHolder;
        }
    }





This is what is traced back to me.

Code:
Sat Aug 9 10:50:17 GMT-0400 2008
7/9/2008
Sun Aug 10 10:50:17 GMT-0400 2008
7/10/2008
Mon Aug 11 10:50:17 GMT-0400 2008
7/11/2008 ... and etc
that code is within the same function but once i try to format as month/day/year it somehow sets it self a month earlier. Any ideas? any help? thanks in advance!

Hours Between Two Dates
Is it possible to use:

TargetDate = new Date(Date.UTC(2003,10,1,1));

EndDate = new Date(Date.UTC(2004,10,1,1));

To establish the number of hours in between the two dates?

M@?

Evaluating Dates
i have the following strings: "3/11/2003 11:12:54" and "12/15/2003 8:59:06"

how can i evaluate only the date portion to determine if the first date is before the second date.

doest that make sense?

thanx for your help.

Copyright © 2005-08 www.BigResource.com, All rights reserved