C# Current Time Calc issue.

Hey there guys,

I’m trying to calculate the current time using the following script in C#

public int currentHour;
	public int currentMin;

	public int hoursInSeconds;
	public int minutesInSeconds;

	public int timeOfDay;
	protected string currentHourTime;
	//public int	clockHour;
	//public string timeOfDayPhrase;

	void getTimeofDay(){

		currentHour = System.DateTime.Minute;
		currentMin = System.DateTime.Minute;
		hoursInSeconds = (currentHour) * 60.0 * 60.0;
		minutesInSeconds = (currentMin) * 60.0;
		timeOfDay = (hoursInSeconds) + (minutesInSeconds);
		Debug.Log (timeOfDay);


I received a number of errors when I ran this script. Firstly that system.DateTime does not return an int. It returns string. One would then conclude to run the debug the script that one would need to convert the string into an int using Int32. I have tried this and nothing of any value happened. Does anyone have any idea how to make this script successful?

All I’m trying to do it quantify the current time into a measurable value I can reference.
Thank you all!

based on this script I found (JS)

If you’re just looking for a way to convert the current date to seconds (since midnight that is based on DateTime.Now) you can use a helper function like this:

Using System;

void Start () {
    int totalSeconds = GetSeconds(DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);

public int GetSeconds(int hours, int minutes, int seconds)
    return ((hours * 60) + minutes) * 60 + seconds;