c#中DataTime類型的常用操作整理

1. 獲取當前年月日時分秒:system.DateTime.Now

2. 獲取長日期:xxxx年xx月xx日

3. 獲取短日期:xxxx-xx-xx

4. 構造新日期:

    DateTime now = DateTime.Now;

    DateTime d1 = new DateTime(now.Year,now.Month,1);

5. 當前日期後推三天:

     DateTime later = DateTime.Now.AddDays(3);

6. string轉DateTime

    DateTime.parse(string str);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章