unity中获取七天的日期

    private List<string> Date;
    private List<string> Day;
    private string now;
    private WMG_Axis_Graph m_WMG_Axis_Graph;



    void Start ()
    {
        Date = new List<string>();
        Day = new List<string>();

        for (int i = 6; i >= 0 ; i--)
        {
          string date = getDateCon(now, -i);
          string day = getDayCon(now, -i);

          Date.Add(date);
          Day .Add(day);

        }
        //  Debug.Log(Date[1]+Date[2]);
        m_WMG_Axis_Graph = this.gameObject.GetComponent<WMG_Axis_Graph>();
        m_WMG_Axis_Graph.xAxisLabels = Date;


    }

    public string getDateCon(string _date,int i)
    {

        _date = DateTime.Now.AddDays(i).ToString();
        //Debug.Log(_date);
        char[] chs = { '/' };
        string[] date2 = _date.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
        _date = date2[0] + "/" + date2[1];
         // Debug.Log(_date);       
        return _date;
    }
    public string getDayCon(string _day, int i)
    {

        _day = DateTime.Now.AddDays(i).ToString();
        char[] chs = { '/' };
        string[] date2 = _day.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
        _day = date2[1];       
        return _day;
    }

 

posted @ 2017-11-30 12:45  U3DEngineer  阅读(1157)  评论(0编辑  收藏  举报