datetime help

idk what thread to put this in.

how do i do somthing like this

DateTime d = System.DateTime.UtcNow.Day,System.DateTime.UtcNow.Month,System.DateTime.UtcNow.Year,9,00,00;

im trying to make a timer that runs outside of the app.
my scripts:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class TimerMaster : MonoBehaviour
{
    DateTime currentDate;
    DateTime oldDate;

    public string saveLocation;
    public static TimerMaster instance;
    // Start is called before the first frame update
    void Awake()
    {
        instance = this;

        saveLocation = "lastSavedDate1";
    }

    public float CheckDate()
    {
        currentDate = System.DateTime.UtcNow;

        string tempString = PlayerPrefs.GetString(saveLocation, "1");

        long tempLong = Convert.ToInt64(tempString);

        DateTime oldDate = DateTime.FromBinary(tempLong);

        TimeSpan difference = currentDate.Subtract(oldDate);

        return (float)difference.TotalSeconds;
    }


    public float MyCheckDate()
    {
        currentDate = System.DateTime.UtcNow;
       
        DateTime d = System.DateTime.UtcNow.Day,System.DateTime.UtcNow.Month,System.DateTime.UtcNow.Year,9,00,00;
        DateTime oldDate = Convert.ToDateTime(d);

        TimeSpan difference = currentDate.Subtract(oldDate);

        return (float)difference.TotalSeconds;
    }

    public void SaveDate()
    {
        PlayerPrefs.SetString(saveLocation, System.DateTime.Now.ToBinary().ToString());
    }



}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using System;
public class Timer : MonoBehaviour
{
    public float timer;
    public int t;
    private bool Started = false;
    public TMP_Text text;
    // Start is called before the first frame update
    void Start()
    {
        Started = PlayerPrefsX.GetBool("s");
        if (Started)
        {
            timer = 86400;

            timer -= TimerMaster.instance.CheckDate();
        }
        else
        {
            Started = true;
            PlayerPrefsX.SetBool("s", Started);

            timer = 86400;
            timer -= TimerMaster.instance.MyCheckDate();
        }
    }

    // Update is called once per frame
    void Update()
    {
        timer -= Time.deltaTime;
        if(timer <= 0)
        {
            float o = timer;
            timer = 86400;
            timer += o;
            t += 1;
        }


        TimeSpan timeSpan = TimeSpan.FromSeconds(timer);
        string timeText = string.Format("{0:smile:2}:{1:smile:2}:{2:smile:2}", timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
        text.text = timeText;
    }

    public void ResetTimer()
    {
        timer = 86400;
        TimerMaster.instance.SaveDate();
        PlayerPrefsX.SetBool("s", false);
    }
}

i want the timer to end at 9 pm and restart i have everything but the 9.00 part

You can use DateTime.Subtract() to compare dates and times when your app relaunches to see how long has passed.

If you need it to wake up your app at 9pm, that is outside the scope of Unity. You can look into push notifications on certain platforms such as Android or iOS, but otherwise it would be a cron job or Windows Scheduler job in a desktop operating system to launch your app.

No what i’m saying is if a new player starts the game and its 8:00 the timer would display 1 hour i have everything else in like it resets and runs outside the app i just need to tell how far away is the time from 9:00 at the start of the game and itl only run once.

I will say it again:

You load one time up, then subtract the other, and it gives you a difference.

I know. Look

    public float CheckDate()
    {
        currentDate = System.DateTime.Now;
        string tempString = PlayerPrefs.GetString(saveLocation, "1");
        long tempLong = Convert.ToInt64(tempString);
        DateTime oldDate = DateTime.FromBinary(tempLong);
        TimeSpan difference = currentDate.Subtract(oldDate);
        return (float)difference.TotalSeconds;
    }
    public void SaveDate()
    {
        PlayerPrefs.SetString(saveLocation, System.DateTime.Now.ToBinary().ToString());
    }

Pls change this to find the difference between current time & 9:00