I want to compare 2 dates but its not working!

On close I run this:
PlayerPrefs.SetString(“PlayDate”, System.DateTime.Now.ToBinary().ToString());

On start I run this:
long temp = Convert.ToInt64(PlayerPrefs.GetString(“PlayDate”));
DateTime oldDate = DateTime.FromBinary(temp);

I get this:
FormatException: Input string was not in the correct format System.Int64.Parse (System.String s)

If I try this on close:
currentDate = System.DateTime.Now;
long date_bin = currentDate.ToBinary();
PlayerPrefs.SetString(“PlayDate”, date_bin.ToString());

and try this on open:
long oldDate = long.Parse(PlayerPrefs.GetString(“PlayDate”));
DateTime oldDate = DateTime.FromBinary(oldDate);

I get this:
FormatException: Input string was not in the correct format System.Int64.Parse (System.String s)

How do I Save the date and time someone starts playing. If they start playing again 23 hours later or while still playing and the 23 hour passes, add 10 to an int variable.

Anything I try doesn’t work, says the system can’t convert binary to long because the string isn’t in the right format. It was working at some point, but its not working anymore for no reason… I changed nothing, and now the string is not being stored into PlayerPrefs properly?

I don’t care how the time is stored to PlayerPrefs as long as I can get it back out to compare the time with another using TimeSpan difference = currentDate.Subtract(oldDate);

@kevin5141 compare DateTime.Ticks instead DateTime.Ticks Property (System) | Microsoft Learn