Looking For A Better Way To Check If Day Has Passed

Currently I’m using this method to check to see if a day has passed since the user has asked a certain question. My method is working fine for the shortTimePassed,
BUT is not accurate enough for the dayHasPassed,
Since it is making a comparison based on the last time the question was asked and then the current time, so if you asked the question later in the day it would not be until later that same time the next day that it would consider a day has passed which is not what I want.
Is there another way to handle the dayHasPassed, ??

This is my code snippet:

DateTime currentDate;
	DateTime oldDate;

	public static bool dayHasPassed = false;		// "Are You A Spaceship?" One Day Passed
	public static bool shortTimePassed = false;		// "Are You A Spaceship?" Short Time Passed

	public static bool dayHasPassedQ02 = false;		// "Are We Friends?" One Day Passed
	public static bool shortTimePassedQ02 = false;	// "Are We Friends?" Short Time Passed

	public static bool dayHasPassedQ03 = false;		// "?" One Day Passed
	public static bool shortTimePassedQ03 = false;	// "?" Short Time Passed



	void Start()
	{
		Q01 ();		// "Are You A Spaceship?"
		Q02 ();		// "Are We Friends?"
	}


	// Q01 "Are You A Spaceship?"
	public void Q01(){
		//Store the current time when it starts
		currentDate = System.DateTime.Now;

		//Grab the old time from the player prefs as a long
		long temp = Convert.ToInt64(PlayerPrefs.GetString("sysString"));

		//Convert the old time from binary to a DataTime variable
		DateTime oldDate = DateTime.FromBinary(temp);
		print("oldDate: " + oldDate);

		//Use the Subtract method and store the result as a timespan variable
		TimeSpan difference = currentDate.Subtract(oldDate);
		print("Difference: " + difference);

		if (difference.Days == 1) {
			Debug.Log ("One Day Has Passed From old Date That You Asked If I Was A Spaceship");
			dayHasPassed = true;
		}
		// Either 0 Days Or More Than 2 Days
		if (difference.Days <= 0 || difference.Days >= 2) {
			dayHasPassed = false;
			Debug.Log ("At Least One Day Has NOT YET Passed From old Date That You Aksed If I Was A Spaceship");
		} 
		if (difference.Minutes <= 20){
			Debug.Log ("It Hasn't Even Been 20 Minutes Since You Aksed If I Was A Spaceship");
			shortTimePassed = true;
		}
		if (difference.Minutes >= 21){
			Debug.Log ("More Than 20 Has Passed Since you Aksed If I Was A Spaceship");
			shortTimePassed = false;
		}
	}

Thanks @Glurth,
I’ll experiment a bit with that tomorrow and let you know how it goes, got company over now so I’ll have to play about with it tomorrow :slight_smile:

I Had A little time to experiment… When I changed the code with the new blocks you provided it
Reded out the .Date() parts?

public void Q01(){
		//Store the current time when it starts
		currentDate = System.DateTime.Now;
		//currentDate = System.DateTime.Now.Date();

		//Grab the old time from the player prefs as a long
		long temp = Convert.ToInt64(PlayerPrefs.GetString("sysString"));

		//Convert the old time from binary to a DataTime variable
		//DateTime oldDate = DateTime.FromBinary(temp).Date();
		DateTime oldDate = DateTime.FromBinary(temp);
		print("oldDate: " + oldDate);

		//Use the Subtract method and store the result as a timespan variable
		TimeSpan difference = currentDate.Subtract(oldDate);
		print("Difference: " + difference);