风言枫语  

距离某一天还有多久,简单的小例子.

 

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);
	}
}


 

 

posted on 2013-08-27 19:01  风言枫语  阅读(232)  评论(0编辑  收藏  举报