1 // 昨天,今天,明天 2 DateTime yest = DateTime.Today.AddDays(-1); 3 DateTime Today = DateTime.Today; 4 DateTime Tomo =DateTime.Today.AddDays(1); 5 6 // 2012/12/24 7 System.DateTime.Now.ToString("d"); 8 9 // 2012/12/24 下午 4:30:15 10 System.DateTime.Now.ToString("G"); 11 12 // 2012/12/24 下午 4:30 13 System.DateTime.Now.ToString("g"); 14 15 //16:30:15 16 System.DateTime.Now.ToString("T"); 17 18 //16:30 19 System.DateTime.Now.ToString("t"); 20 21 //Dec, 24 Apr 2012 16:30:15 GMT 22 System.DateTime.Now.ToString("r"); 23 System.DateTime.Now.ToString("R"); 24 25 //2012-04-24 15:52:19 26 System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff"); 27 28 //12-12 29 System.DateTime.Now.ToString("M/yy"); 30 31 //24-12-12 32 System.DateTime.Now.ToString("dd-MM-yy");
有些好像錯誤了,要實際測試一下。