BLOG zzy.my

合抱之木, 生于毫末; 九层之台, 起于累土; 千里之行, 始于足下。

System.DateTime ToString()的一些格式

//2007424

System.DateTime.Now.ToString("D");

 

//2007-4-24

System.DateTime.Now.ToString("d");

 

//2007424 16:30:15

System.DateTime.Now.ToString("F");

 

//2007424 16:30

System.DateTime.Now.ToString("f");

 

//2007-4-24 16:30:15

System.DateTime.Now.ToString("G");

 

//2007-4-24 16:30

System.DateTime.Now.ToString("g");

 

//16:30:15

System.DateTime.Now.ToString("T");

 

//16:30

System.DateTime.Now.ToString("t");

 

//2007424 8:30:15

System.DateTime.Now.ToString("U");

 

//2007-04-24 16:30:15Z

thSystem.DateTime.Now.ToString("u");

 

//424

System.DateTime.Now.ToString("m");

System.DateTime.Now.ToString("M");

 

//Tue, 24 Apr 2007 16:30:15 GMT

System.DateTime.Now.ToString("r");

System.DateTime.Now.ToString("R");

 

//20074

System.DateTime.Now.ToString("y");

System.DateTime.Now.ToString("Y");

 

//2007-04-24T15:52:19.1562500+08:00

System.DateTime.Now.ToString("o");

System.DateTime.Now.ToString("O");

 

//2007-04-24T16:30:15

System.DateTime.Now.ToString("s");

 

//2007-04-24 15:52:19

System.DateTime.Now.ToString("yyyy-MM-dd HHmmssffff");

 

//20070424 155648

System.DateTime.Now.ToString("yyyyMMdd HHmmss");

 

//星期二, 四月 24 2007

System.DateTime.Now.ToString("dddd, MMMM dd yyyy");

 

//, 四月24 '07

System.DateTime.Now.ToString("ddd, MMM d \"'\"yy");

 

//星期二, 四月24

System.DateTime.Now.ToString("dddd, MMMM dd");

 

//4-07

thiSystem.DateTime.Now.ToString("M/yy");

 

//24-04-07

System.DateTime.Now.ToString("dd-MM-yy");

 

//字符型转换转为字符串

12345.ToString("n"); //生成12,345.00

12345.ToString("C"); //生成12,345.00

12345.ToString("e"); //生成1.234500e+004

12345.ToString("f4"); //生成12345.0000

12345.ToString("x"); //生成3039 (16进制)

12345.ToString("p"); //生成1,234,500

 

Loading