unity中获取七天的日期

时间:2025-05-12 17:06:32
    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 = ; i >= ; 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[] + "/" + date2[];
// 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[];
return _day;
}