Get System time in seconds

I’ve heared that Computes just count every second since the year 2000 to tell the time. Can i read this number from anywhere? It would be quite useful in my new game.

The computer counts the time since midnight on January 1, 1970, this is called Unix Time.

It’s very easy to get it.
You can create a static TimeUtils class and call its methods from any part of the program.

using System;

public static class TimeUtils
{
    /// <summary>
    /// Returns Unix Time in seconds
    /// </summary>
    public static int GetUnixTime()
    {
        return (int) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
    }

    /// <summary>
    /// Returns current day number
    /// </summary>
    public static int GetCurrentDayNumber()
    {
        return (int) DateTime.Now.DayOfWeek;
    }

    /// <summary>
    /// Returns current day name
    /// </summary>
    public static string GetCurrentDayName()
    {
        return DateTime.Now.DayOfWeek.ToString();
    }

    /// <summary>
    /// Returns current hour and minutes
    /// </summary>
    public static string GetCurrentTime()
    {
        return DateTime.Now.ToString("HH:mm");
    }
}

and then use it anywhere.

using UnityEngine;

public class TimeUtilsUsingSample : MonoBehaviour
{
    private void Update()
    {
        Debug.Log(TimeUtils.GetUnixTime());
        Debug.Log(TimeUtils.GetCurrentDayNumber());
        Debug.Log(TimeUtils.GetCurrentDayName());
        Debug.Log(TimeUtils.GetCurrentTime());
    }
}