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. 

Tip: You can get the NAME of the day by typing “ddd” or “dddd”. Try this:
print(“Today is ” + System.DateTime.UtcNow.ToLocalTime().ToString(“dddd”));


❤️ Subscribe to Oxmond Tutorials channel. 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 

😷👕 Need a face mask / developer T-shirt? Drop by our shop and get a 20% DISCOUNT on your first purchase by using the discount code OXMONDSALE. Click here:
https://shop.oxmond.com/discount/OXMONDSALE


The Date script:

/*

   .-------.                             .--.    .-------.     .--.            .--.     .--.        
   |       |--.--.--------.-----.-----.--|  |    |_     _|--.--|  |_.-----.----|__|---.-|  |-----.
   |   -   |_   _|        |  _  |     |  _  |      |   | |  |  |   _|  _  |   _|  |  _  |  |__ --|
   |_______|__.__|__|__|__|_____|__|__|_____|      |___| |_____|____|_____|__| |__|___._|__|_____|
   © 2019 OXMOND / www.oxmond.com 

*/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class Date : MonoBehaviour
{

    public TextMeshPro largeText;

    void Start()
    {
        string time = System.DateTime.UtcNow.ToLocalTime().ToString("dd-MM-yyyy   HH:mm");
        string timeUS = System.DateTime.UtcNow.ToLocalTime().ToString("M/d/yy   hh:mm tt");
        largeText.text = time + "[breaktag]" + timeUS;
    }
}

EXTRA: You can detect if it is night with this little script:

using UnityEngine;

public class DayOrNight : MonoBehaviour
{
    void Start()
    {
        int hourInt = System.DateTime.Now.Hour;
        bool night = false;

        if (hourInt <= 6 || hourInt >= 22) {
            night = true;
        }      
        print("Night: " + night);
    }
}