[Plugin] System date and time

From the Asset Store
Create complex dialogues with ease with this tool/template!
  • Naji

  • Hi Im working on a Christmas Calendar

    Can I setup an event/action to only be active on a date for december

    using this plugin ?

    Cheers

    Flemming

  • flemmig

    I guess you need to check the date to see if now is at a specific day.

    + every tick

    + Date.Month = 12

    + Date.Date = 25

    • do someting...
  • This plugin is really useful for me. Thank you very much.

    I have a (probably noob) question: Is it possible to print the year only with the las two digits? i.e.: just '14' instead of '2014'.

    Thanks again,

    Fer

  • FERdeBOER

    str(Date.Year % 100)

  • FERdeBOER

    str(Date.Year % 100)

    That's definitively better than what I was thinking about, passing it to a variable and substracting 2000

    Thank you very much!

  • To author:

    i had analyzed your code and i found the problems

    Exps.prototype.Year = function (ret, timestamp)
    	{
    	    var today = (timestamp != null)? new Date(timestamp): new Date();
    		ret.set_int(today.getFullYear());
    	};
    
    .....
    
    Exps.prototype.UnixTimestamp = function (ret)
    	{
    	    var today = new Date();
            ret.set_float(today.getTime());
    	};
    [/code:3dp5k345]
    
    reference:http://www.w3schools.com/js/js_dates.asp
    JavaScript dates are [b]calculated in milliseconds[/b] from 01 January, 1970 00:00:00 Universal Time (UTC).
    One day contains 86,400,000 millisecond.
    
    seems in javascript
    a Date object include milliseconds (1 second = 1000 milliseconds) and the standard unix timestamp is 1421664587 (2015/1/19 18:49:47 GMT+8) is NOT include milliseconds part
    so the unix timestamp should multiply by 1000 to 1421664587000
    [quote:3dp5k345][unix timestamp] * 1000 = [java Date]
    1421664587 * 1000 = 1421664587000
    
    
    to get a unix timestamp from Date object just need to Date.getTime() divide by 1000
    [quote:3dp5k345][java Date] / 1000 = [unix timestamp]
    1421664587000 / 1000 = 1421664587
    
    
    [code:3dp5k345]
    Exps.prototype.Year = function (ret, timestamp)
    	{
    	    var today = (timestamp != null)? new Date(timestamp*1000): new Date();
    		ret.set_int(today.getFullYear());
    	};
    
    ...
    Exps.prototype.UnixTimestamp = function (ret)
    	{
    	    var today = new Date();
            ret.set_float(today.getTime()/1000);
    	};
    [/code:3dp5k345]
    
    and i modified the plugin to above code
    i got a correct result to convert from unix timestamp to Year
    This is what i suggest in your next update
    i wish this may help you to solve this problems
  • fongka2

    Yes, the return value is based on milliseconds, which described in ACE table.

    Expression:UnixTimestamp Get current number of milliseconds since the epoch.[/code:2koe22b7]
    Since users had used it based on milliseconds, the changing will break their projects.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you Rex. Great plugin. This is exactly what I needed.

  • Thanks, Rexrainbow!

  • I might be too new at this, but I'm having a hard time understanding how to use the plugin. The mechanics are there but I'm just not getting it.

    I made a very simple "digital pet" app and I wanted your plugin to check the time since the user last logged in. I need to use this data in order to assign the "pets" age variable. Do you have a simple example of how I could do this?

    Thank you.

  • TheSynan

    Try rex_time_away plugin.

    Call "Action:Start timer" when left. You might need to call it every tick (or every second/minute) to prevent left game without logging out.

    Then get the elapsed time by "Expression:ElapsedTime" at next login.

  • TheSynan

    Try rex_time_away plugin.

    Call "Action:Start timer" when left. You might need to call it every tick (or every second/minute) to prevent left game without logging out.

    Then get the elapsed time by "Expression:ElapsedTime" at next login.

    So, start the timer on end of layout?

    At start of layout get elapsedtime?

    :/ Maybe I should read up some more haha.

  • TheSynan

    Yes, you might try the sample capx appended in document.

  • This is just beautiful! Thank you very much

    Now I can make a neat addition to my desktop app.

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