距离某一天还有多久,简单的小例子.
using UnityEngine; using System.Collections; using System; public class test : MonoBehaviour { DateTime dt1; DateTime dt2; TimeSpan ts; public GameObject mObj; private UILabel mLab; // Use this for initialization void Start () { dt2 = new DateTime(2014,1,18); mLab = mObj.GetComponent<UILabel>(); } // Update is called once per frame void Update () { dt1 = DateTime.Now; ts = dt1.Subtract(dt2); mLab.text = ts.ToString(); Debug.Log(ts); } }