How to work with date and time. In this tutorial we’ll work with the system datetime. How to get it, and how to format it. 


Subscribe to Oxmond Tutorials. We upload new videos every day!
https://bit.ly/SubscribeOxmondTutorials

Download Free Assets from the Unity Assets Store:
https://assetstore.unity.com/lists/top-free-packages-13201?aid=1100l4p9k 

Some links might be affiliate links. Any support is truly appreciated so we can keep on making high quality content 🙂


Generate a random number:

   private void PickRandomNumber(int maxInt) {
        int randomNum = Random.Range(1, maxInt+1);
        print(randomNum);
    }

Pick a random name from a list:

      private void PickRandomFromList() {
        string[] students = new string[] { "Harry", "Ron", "Hermione" };
        string randomName = students[Random.Range(0, students.Length)];
        print(randomName);
    }

Generate a random string:

    private void CreateRandomString(int stringLength = 10) {
        int _stringLength = stringLength - 1;
        string randomString = "";
        string[] characters = new string[] { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
        for (int i = 0; i <= _stringLength; i++) {
            randomString = randomString + characters[Random.Range(0, characters.Length)];
        }
        print(randomString);
    }