Saving System.DateTime in a Serialized Scriptable Object is defaulting

Hey there!
I have a Serializable Class called SaveFile with a System.DateTime field in it.
However when I load the Scriptable Object with the SaveFile Class in it all the System.DateTime fields default to January 1st, 0001, Midnight.
Is there a way to keep the fields as System.DateTime rather than saving it as a value type and converting back and forth?

Any help would be great! Thanks!
Thanks!

EDIT
Also wanted to mention that way to save the timestamp is to use a ‘long’ and get the Ticks property from the DateTime struct.

long myTimeStamp = System.DateTime.Now.Ticks;

Then when you want to use DateTime functionality:

new System.DateTime(myTimeStamp);

Unity can’t serialize DateTime values. Have a look at script serialization. There’s a list of types Unity can serialize. You can implement the “ISerializationCallbackReceiver” interface as shown in the manual and serialize the DateTime value to a value that Unity can serialize.

I would recommend wrapping it in a class that can be serialized and lazily creates the DateTime once first accessed:

using System;
using UnityEngine;

namespace Supyrb
{
	[System.Serializable]
	public class SerializableDateTime : IComparable<SerializableDateTime>
	{
		[SerializeField] 
		private long m_ticks;

		private bool initialized;
		private DateTime m_dateTime;
		public DateTime DateTime
		{
			get
			{
				if (!initialized)
				{
					m_dateTime = new DateTime(m_ticks);
					initialized = true;
				}

				return m_dateTime;
			}
		}

		public SerializableDateTime(DateTime dateTime)
		{
			m_ticks = dateTime.Ticks;
			m_dateTime = dateTime;
			initialized = true;
		}

		public int CompareTo(SerializableDateTime other)
		{
			if (other == null)
			{
				return 1;
			}
			return m_ticks.CompareTo(other.m_ticks);
		}
	}
}

You can then use the class the following way:

[SerializeField]
public SerializableDateTime now;
....
now = new SerializableDateTime(DateTime.Now);
Debug.Log(now.DateTime);