Code
asp.net中的日期处理函数
//2007年4月24日
this.textbox6.text = system.datetime.now.tostring("d");
//2007-4-24
this.textbox7.text = system.datetime.now.tostring("d");
//2007年4月24日 16:30:15
this.textbox8.text = system.datetime.now.tostring("f");
//2007年4月24日 16:30
this.textbox9.text = system.datetime.now.tostring("f");
//2007-4-24 16:30:15
this.textbox10.text = system.datetime.now.tostring("g");
//2007-4-24 16:30
this.textbox11.text = system.datetime.now.tostring("g");
//16:30:15
this.textbox12.text = system.datetime.now.tostring("t");
//16:30
this.textbox13.text = system.datetime.now.tostring("t");
//2007年4月24日 8:30:15
this.textbox14.text = system.datetime.now.tostring("u");
//2007-04-24 16:30:15z
this.textbox15.text = system.datetime.now.tostring("u");
//4月24日
this.textbox16.text = system.datetime.now.tostring("m");
this.textbox16.text = system.datetime.now.tostring("m");
//tue, 24 apr 2007 16:30:15 gmt
this.textbox17.text = system.datetime.now.tostring("r");
this.textbox17.text = system.datetime.now.tostring("r");
//2007年4月
this.textbox19.text = system.datetime.now.tostring("y");
this.textbox19.text = system.datetime.now.tostring("y");
//2007-04-24t15:52:19.1562500+08:00
this.textbox20.text = system.datetime.now.tostring("o");
this.textbox20.text = system.datetime.now.tostring("o");
//2007-04-24t16:30:15
this.textbox18.text = system.datetime.now.tostring("s");
//2007-04-24 15:52:19
this.textbox21.text = system.datetime.now.tostring("yyyy-mm-dd hh:mm:ss:ffff");
//2007年04月24 15时56分48秒
this.textbox22.text = system.datetime.now.tostring("yyyy年mm月dd hh时mm分ss秒");
//星期二, 四月 24 2007
this.textbox1.text = system.datetime.now.tostring("dddd, mmmm dd yyyy");
//二, 四月 24 '07
this.textbox2.text = system.datetime.now.tostring("ddd, mmm d \"'\"yy");
//星期二, 四月 24
this.textbox3.text = system.datetime.now.tostring("dddd, mmmm dd");
//4-07
this.textbox4.text = system.datetime.now.tostring("m/yy");
//24-04-07
this.textbox5.text = 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
asp.net中的日期处理函数
//2007年4月24日
this.textbox6.text = system.datetime.now.tostring("d");
//2007-4-24
this.textbox7.text = system.datetime.now.tostring("d");
//2007年4月24日 16:30:15
this.textbox8.text = system.datetime.now.tostring("f");
//2007年4月24日 16:30
this.textbox9.text = system.datetime.now.tostring("f");
//2007-4-24 16:30:15
this.textbox10.text = system.datetime.now.tostring("g");
//2007-4-24 16:30
this.textbox11.text = system.datetime.now.tostring("g");
//16:30:15
this.textbox12.text = system.datetime.now.tostring("t");
//16:30
this.textbox13.text = system.datetime.now.tostring("t");
//2007年4月24日 8:30:15
this.textbox14.text = system.datetime.now.tostring("u");
//2007-04-24 16:30:15z
this.textbox15.text = system.datetime.now.tostring("u");
//4月24日
this.textbox16.text = system.datetime.now.tostring("m");
this.textbox16.text = system.datetime.now.tostring("m");
//tue, 24 apr 2007 16:30:15 gmt
this.textbox17.text = system.datetime.now.tostring("r");
this.textbox17.text = system.datetime.now.tostring("r");
//2007年4月
this.textbox19.text = system.datetime.now.tostring("y");
this.textbox19.text = system.datetime.now.tostring("y");
//2007-04-24t15:52:19.1562500+08:00
this.textbox20.text = system.datetime.now.tostring("o");
this.textbox20.text = system.datetime.now.tostring("o");
//2007-04-24t16:30:15
this.textbox18.text = system.datetime.now.tostring("s");
//2007-04-24 15:52:19
this.textbox21.text = system.datetime.now.tostring("yyyy-mm-dd hh:mm:ss:ffff");
//2007年04月24 15时56分48秒
this.textbox22.text = system.datetime.now.tostring("yyyy年mm月dd hh时mm分ss秒");
//星期二, 四月 24 2007
this.textbox1.text = system.datetime.now.tostring("dddd, mmmm dd yyyy");
//二, 四月 24 '07
this.textbox2.text = system.datetime.now.tostring("ddd, mmm d \"'\"yy");
//星期二, 四月 24
this.textbox3.text = system.datetime.now.tostring("dddd, mmmm dd");
//4-07
this.textbox4.text = system.datetime.now.tostring("m/yy");
//24-04-07
this.textbox5.text = 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