Skip to main content
Inspiring
February 7, 2023
Question

Calculate date from present day

  • February 7, 2023
  • 4 replies
  • 878 views

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

    This topic has been closed for replies.

    4 replies

    Inspiring
    February 21, 2023

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

    Inspiring
    February 21, 2023

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

    Inspiring
    February 21, 2023
    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;
    
    Inspiring
    February 21, 2023

     

    kglad
    Community Expert
    Community Expert
    February 7, 2023

    as3 or js?

    Inspiring
    February 7, 2023
    as3
    kglad
    Community Expert
    Community Expert
    February 7, 2023

    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;
    }

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