How to calculate # days from 11/15/2023 - and then calculate interest at 4.75% for $1 every second?

0 favourites
  • 2 posts
From the Asset Store
15 main themes, 15 in-game loops and 26 music stingers for casual games.
  • I'm a total novice. I'm using Construct 2. If anybody could possibly answer this question, or better yet, provide me with a sample that I can load in Construct 2, I would be most appreciative.

    1. I'd like the program to ask the user what todays date is. (I found it tooooo confusing for me to use plugins to determine the date)... so merely asking the user to input the date themself seems like the easiest solution.

    2. After the user inputs todays date, I would like the program to calculate the number of DAYS since 11/15/2023. <-- Yes.. the number of days from the EXACT date of 11/15/2023.

    Does anybody know of an EASY way to do this with no plugins?

    MORE DETAILS PROBABLY NOT NEEDED:

    I'm trying to create a program that will calculate interest at 4.75% starting from the date 11/15/23 starting with the principal amount of $1. I do NOT want to use plugins... just something super simple. But i want the program to show the compounding interest every second forever... kind of like a ticker that ticks up every SECOND showing how much I make every second in interest at 4.75%

    I'm NOT sure how to do this.. but I think if I can get the first part solved (tell me the exact number of days from 11/25/2023 after the user manually inputs todays date), perhaps I can hopefully figure out the rest.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This is very simple in C3.

    Use build-in Date Plugin #open=date-time

    Example:

    Date.ToTotalHours(Date.Difference(Date.Parse("2023-11-15"), Date.Parse("2023-11-20"))) / 24

    If you also need to display localized currency units, then this will also be helpful to you #open=internationalization

    ---

    OR You can use Javascript to calculate, Here is an example:

    function calculateDaysDifference(userDate) {

    const startDate = new Date('2023-11-15');

    const endDate = new Date(userDate);

    const diffInTime = endDate.getTime() - startDate.getTime();

    const diffInDays = Math.floor(diffInTime / (1000 * 3600 * 24));

    return diffInDays;

    }

    ---

    Example:

    calculateDaysDifference('2023-11-20')

    Output:

    5

    ---

    But if you are talking about C2, you may need to use Brower to execute JavaScript.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)