How do I Get Month and Day and Year?

0 favourites
  • 12 posts
From the Asset Store
Action packed 2 track pack for use in your projects
  • Hi I want to be able to show the month and day in a text box formatted like this

    and then in another text box I would like to show the year

    but how do i do this as I have tried Date() but it returns everything which i dont want.

    Tagged:

  • newt I have tried with the browser js for example getFullYear() but it returns 0 what am i doing wrong

    i used this code Browser.ExecJS("getFullYear()")

    EDIT IT WORKS NOW

    BUT how do i see if its the next day as i want to call an api once daily so i dont call it every time the app opens how would i do this?

  • I would use "unixtime" and compare the milliseconds in a day.

    So if unixtime-86400000 => storedUnixtime, then you know its a day

  • I would use "unixtime" and compare the milliseconds in a day.

    So if unixtime-86400000 => storedUnixtime, then you know its a day

    newt what do you mean by storedUnixtime as i cant seem to find that command?

  • Its not.

    Store the current unixtime in local storage when they first log in.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is the method I use to get the current Day, Month, and Year into a specific format. I hope this helps because if you study the commands I used it should get you there. Good Luck!

    FYI - I use this for a variables I want to change every Earth Day... like the location of a key item.. etc

    Gillis

  • Thanks Gillis and newt but am i right in saying newt your calculation - calculates if its been a full day since the user started playing?

    But I'm slightly confused on how to calculate the next day -- if you understand where I'm coming from :)

  • When the player initially starts the game save the date, unixtime to localstorage.

    When the player starts the game again, compare that date to the current one.

    If the time elapsed is equal to a day, overwrite the current local storage to the current date.

    Obviously if the game doesn't get restarted all the time, then you will need to check the time occasionally.

  • newt i have tried heres a pic

    but the checkIfNew day function seems to run even when the variables are equal? which i think might be a c3 glitch

  • Here's an example using 30 seconds

    dropbox.com/s/my90ee9q6t7gdfn/unixtimecheck.c3p

    Change 30000 to 86400000, and check back tomorrow.

  • Here's an example using 30 seconds

    https://www.dropbox.com/s/my90ee9q6t7gdfn/unixtimecheck.c3p?dl=1

    Change 30000 to 86400000, and check back tomorrow.

    Thanks I will look at it now and let you know

    EDIT:: I cant thank you enough newt -- 30 second version works fine -- i cant believe how this could be done so simply :) -- i was hardcoding it!!

    I will update this in 24 hrs time!

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