asp.net中System.DateTime.Now.ToString()的一些用法
Asp.net中的日期处理函数
字符型转换 转为字符串
1
//2009年4月24日
2
this.TextBox6.Text = System.DateTime.Now.ToString("D");
3
//2009-4-24
4
this.TextBox7.Text = System.DateTime.Now.ToString("d");
5![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
//2009年4月24日 16:30:15
7
this.TextBox8.Text = System.DateTime.Now.ToString("F");
8
//2009年4月24日 16:30
9
this.TextBox9.Text = System.DateTime.Now.ToString("f");
10![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
//2009-4-24 16:30:15
12
this.TextBox10.Text = System.DateTime.Now.ToString("G");
13
//2009-4-24 16:30
14
this.TextBox11.Text = System.DateTime.Now.ToString("g");
15![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
//16:30:15
17
this.TextBox12.Text = System.DateTime.Now.ToString("T");
18
//16:30
19
this.TextBox13.Text = System.DateTime.Now.ToString("t");
20![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
//2009年4月24日 8:30:15
22
this.TextBox14.Text = System.DateTime.Now.ToString("U");
23
//2009-04-24 16:30:15Z
24
this.TextBox15.Text = System.DateTime.Now.ToString("u");
25![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
//4月24日
27
this.TextBox16.Text = System.DateTime.Now.ToString("m");
28
this.TextBox16.Text = System.DateTime.Now.ToString("M");
29
//Tue, 24 Apr 2009 16:30:15 GMT
30
this.TextBox17.Text = System.DateTime.Now.ToString("r");
31
this.TextBox17.Text = System.DateTime.Now.ToString("R");
32
//2009年4月
33
this.TextBox19.Text = System.DateTime.Now.ToString("y");
34
this.TextBox19.Text = System.DateTime.Now.ToString("Y");
35
//2009-04-24T15:52:19.1562500+08:00
36
this.TextBox20.Text = System.DateTime.Now.ToString("o");
37
this.TextBox20.Text = System.DateTime.Now.ToString("O");
38
//2009-04-24T16:30:15
39
this.TextBox18.Text = System.DateTime.Now.ToString("s");
40
//2009-04-24 15:52:19
41
this.TextBox21.Text = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:ffff");
42
//2009年04月24 15时56分48秒
43
this.TextBox22.Text = System.DateTime.Now.ToString("yyyy年MM月dd HH时mm分ss秒");
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
20
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
21
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
22
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
23
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
24
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
25
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
26
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
27
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
28
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
29
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
30
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
31
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
32
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
33
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
34
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
35
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
36
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
37
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
38
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
39
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
40
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
41
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
42
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
43
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
字符型转换 转为字符串
1
12345.ToString("n"); //生成 12,345.00
2
12345.ToString("C"); //生成 ¥12,345.00
3
12345.ToString("e"); //生成 1.234500e+004
4
12345.ToString("f4"); //生成 12345.0000
5
12345.ToString("x"); //生成 3039 (16进制)
6
12345.ToString("p"); //生成 1,234,500
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)