DateTime Stamp not working on Android but works in unity editor

I have the following code
I defined this variable in the beginning of my GameManager script :
public string formattedTime = DateTime.UtcNow.ToString(“yyyy-MM-ddTHH:mm:ss”);

and then put a debug message
Debug.Log($“Formatted Time: {formattedTime}”);
in my Play function( so when the player hits the button play). When I check the debug message in the Unity Editor it works perfectly BUT when I check it in the AndroidLogCat it shows as empty. When I check the variable that is saved in the UnityCloud with the player ID of my mobile device I see that it is also empty like this : " ". What could be the problem? Any ideas? I am confused because on the laptop it works perfectly and it is also not throwing me any errors.

Since you wrote

it means that variable will be serialized in the inspector. So your field initializer becomes pretty irrelevant once your project is build as the serialized value will always take precedence / will overwrite the value when the instance is loaded / deserialized. If your variable isn’t actually serialized and does not show up in the inspector, you should provide your actual code. We don’t really like the guessing game :slight_smile:

1 Like