• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
Exit
• Calculate date from present day

# Calculate date from present day

Explorer ,
Feb 07, 2023 Feb 07, 2023

Copied

Hi!

Im totally new in everything relatied to programming, but im trying to do little project of mine and learning while doing it. Im stuck at this simpe coding, which i cant reslove no matter how i try.

I need to make ona frame which i will get by click of button and then it would tell me todays date, +3 days date, +10days date, and +120 days date.Can someone help me pls

thanks

Views

554

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
20 Replies 20
Community Expert ,
Feb 07, 2023 Feb 07, 2023

Copied

as3 or js?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 07, 2023 Feb 07, 2023

Copied

as3

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 07, 2023 Feb 07, 2023

Copied

for whatever number of days you want, create a date object by using dateF().  you can then use it's properties (day, date, month, year etc to display what you want).

var d:Date = new dateF(days);

var d:Date = dateF(days);

// for example, for 3 days from today, var d3:Date = new dateF(3);

var d3:Date = dateF(3);

// for 120 days from today var d120 = new dateF(120);

var d120:Date = dateF(120);

///////////// no need to edit /////////////////

function dateF(days:int):Date{

var d:Date = new Date();

return new Date(d.time+timeF(days));

}

function timeF(days:int):Number{
return days*24*60*60*1000;
}

////////////////////////////////////////////////////////

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 07, 2023 Feb 07, 2023

Copied

well thanks...and how can i put that in dd/mm/yyyy format, UTC...I did have
some code which tranform my time in milliseconds then puts it back in time,
but output for that is in looooong format with time and seconds etc. i dont
need that. I need dd/mm/yyyy format in my designated text input box...when
i clixk button on my present frame, it takes me to this one with all
calculations there in seperate boxes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 07, 2023 Feb 07, 2023

Copied

d120.date+"/"+d.120.month+"/"+d120.year

(or maybe d120.fullYear)

check the as3 date api.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 08, 2023 Feb 08, 2023

Copied

One more question...i want to make menus...in thisnformat

+ blablabla
+ blsblabla
+ blsbksbla
+blabllabka
+ anotheblablabka

Hiw to do it?

So user click those and it opens, until final one, then opens frame...thanks

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 08, 2023 Feb 08, 2023

Copied

Hi.

Maybe @kglad can answer your latest question here, but I think it would be better for you to create another topic so that it will easier for other users to find the possible answers you will receive.

Regards,

JC

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 08, 2023 Feb 08, 2023

Copied

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 08, 2023 Feb 08, 2023

Copied

so...i have one frame. with all the text as follows

+ blabla
+ bla bla
+ blabla
+ blsbka
+ blabla
- blabla
appears...etc....until "-", thats the last submenu item which opens some
frame etc

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 08, 2023 Feb 08, 2023

Copied

use a combobox component.

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 09, 2023 Feb 09, 2023

Copied

How to make it visible in text box?

melb.text = theNewDatenew.toString();

like that or?

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 09, 2023 Feb 09, 2023

Copied

melb.text = d120.date+"/"+(d120.month+1)+"/"+d120.fullYear;

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 09, 2023 Feb 09, 2023

Copied

Scene 1, Layer 'Actions', Frame 640, Line 7 1048: Method cannot be used as a constructor.

var d:Date = new dateF(days);

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 09, 2023 Feb 09, 2023

Copied

``````var d3:Date = new dateF(3);

///////////// no need to edit /////////////////

function dateF(days:int):Date{

var d3:Date = new Date();

return new Date(d3.time+timeF(days));

}

function timeF(days:int):Number{
return days*24*60*60*1000;
}

melb.text = d3.date+"/"+(d3.month+1)+"/"+d3.fullYear;

////////////////////////////////////////////////////////``````

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Feb 09, 2023 Feb 09, 2023

Copied

that's my error.  it should be:

var d:Date = dateF(days);

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 21, 2023 Feb 21, 2023

Copied

``````var rightNow = new Date();
var msRightNow = rightNow.getTime();

var threeDays = 3 * 24 * 60 * 60 * 1000;
var tenDays = 10 * 24 * 60 * 60 * 1000;
var hundredDays = 120 * 24 * 60 * 60 * 1000;

var finalTime3 = msRightNow + threeDays;
var finalTime10 = msRightNow + tenDays;
var finalTime100 = msRightNow + hundredDays;

var theNewDate3 = new Date(finalTime3);
var theNewDate10 = new Date(finalTime10);
var theNewDate100 = new Date(finalTime100);

melb.text = theNewDate3.dateUTC + "-" + (theNewDate3.monthUTC + 1) + "-" + theNewDate3.fullYearUTC;
melc.text = theNewDate10.dateUTC + "-" + (theNewDate10.monthUTC + 1) + "-" + theNewDate10.fullYearUTC;
meld.text = theNewDate100.dateUTC + "-" + (theNewDate100.monthUTC + 1) + "-" + theNewDate100.fullYearUTC;``````

I had these on Flas CS6, and it worked flawless. Now on Animate, i get wierds dates, without some digits...

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 21, 2023 Feb 21, 2023

Copied

``````var rightNow = new Date();
var msRightNow = rightNow.getTime();

var threeDays = 3 * 24 * 60 * 60 * 1000;
var tenDays = 10 * 24 * 60 * 60 * 1000;
var hundredDays = 120 * 24 * 60 * 60 * 1000;

var finalTime3 = msRightNow + threeDays;
var finalTime10 = msRightNow + tenDays;
var finalTime100 = msRightNow + hundredDays;

var theNewDate3 = new Date(finalTime3);
var theNewDate10 = new Date(finalTime10);
var theNewDate100 = new Date(finalTime100);

melb.text = theNewDate3.dateUTC + "-" + (theNewDate3.monthUTC + 1) + "-" + theNewDate3.fullYearUTC;
melc.text = theNewDate10.dateUTC + "-" + (theNewDate10.monthUTC + 1) + "-" + theNewDate10.fullYearUTC;
meld.text = theNewDate100.dateUTC + "-" + (theNewDate100.monthUTC + 1) + "-" + theNewDate100.fullYearUTC;
``````

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 21, 2023 Feb 21, 2023

Copied

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 21, 2023 Feb 21, 2023

Copied

As you see , only 7 digits are present???

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Explorer ,
Feb 21, 2023 Feb 21, 2023

Copied

LATEST

I figure it out, i had to embed font in each text area