Forum rules - please read before posting.

Getting Unix epoch time?

Is it possible to check a variable against unix epoch time without custom coding? I've look everywhere and couldn't find anything so I tried to custom code it myself but I can't seem to figure it out.
Or even set a variable to unix epoch time so I can check that against another variable?

Thanks for any help!

Comments

  • Welcome to the community, @pamkatgo.

    Scripting is necessary, but only a couple of lines.

    After getting the current time as an integer, you can update an AC Global Integer with this value so that it can be compared with others.

    Here's a script that should do it - just create a Global Integer variable named "Epoch Time", and it should get updated whenever the script is present in your scene:

    using System;
    using UnityEngine;
    using AC;
    
    public class SetEpochTime : MonoBehaviour
    {
    
        void Update ()
        {
            DateTime epochStart = new DateTime (1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            int cur_time = (int)(System.DateTime.UtcNow - epochStart).TotalSeconds;
            GlobalVariables.GetVariable ("Epoch Time").IntegerValue = cur_time;
        }
    
    }
    
  • Thank you so much! That works perfectly :smile:

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.