How do I get system date/time in c3 runtime?

0 favourites
  • 5 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • I know of: Browser.ExecJS("Date()")

    I need to know how to extract it to individual variables or to compare it to a specific time, date and day of the week. I don't think the year matters, but would like to know anyway.

    I would like to keep it system time and as simple as possible.

    I tried plugins, but they all seem to be for C2 runtime. They were not showing up in my project and I couldn't figure out why. I made a new project and placed it in c2 runtime and then saw them available.

    I would like my project aware of time so characters can be different places at different times. I also would like to built it so in-game events can start on their own depending on what date/day it is.

    I am planing on only setting Time/date once on start up or not to often during game play. I figure setting a timer would be more efficient on the system than running Javascript command every few seconds.

    Also is there a way to check if JavaScript is working on device? Would it just be by executing JS and comparing variable or is there another way.

  • Set Value strTime mid((Browser.ExecJS("Date()")),17,8)

    Also, this article had an interesting take on elapsed time. if that helps!

    https://www.construct.net/en/forum/construct-3/how-do-i-8/how-do-i-compare-time-between-141171?kws=elapsed%2btime

    Edit: Its not pretty, but you can then use a function to break it down into what you want. Ie: Pass

    Set Value strHour mid((Browser.ExecJS("Date()")),17,2)

    Set Value strMinute mid((Browser.ExecJS("Date()")),20,2) or preferably return it once and work on that variable instead of multiple browser calls.

  • I have seen the UTC Plugin, the download page said it isn't made for c3 runtime yet. I downloaded the example you gave to test and it is only in C2 runtime.

    I don't want to remake objects in c2 runtime because some c3 runtime things are not compatible for c2 runtime.

    I am going to have to lookup your example to understand what mid(text, index, count) does and how to use it. Seems like you pointed me into a direction.

    I will post later to explain it to others or ask more questions if needed.

  • Thank you for showing me Mid()

    It is very easy.

    mid(text, index, count)

    Text is the text you are displaying.

    index is the starting position of the text you want.

    count is how many letters/numbers you want displayed.

    Text= Apple1

    index=0 and count = 3

    will result as 'App'

    index=4 and count=2

    will result as 'e1'

    You have to set variable as String or it may not work correctly.

    I think I will just compare values and if day doesn't equal Mon,Tue,Wed....Sat, Sun then I can assume JavaScript isn't working.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I did some testing and here is some extra info, for those that are learning this.

    Days of Week
    Sun, Mon, Tue, Wed, Thu, Fri, Sat
    Month
    Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec
    Hours
    00, 01.... 11, 12, 13.....23, 00
    Mins
    00, 01, 02.... 58, 59, 00
    Seconds
    00, 01, 02......58, 59, 00
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)