asp笔记1----日期格式输出

来源:互联网 发布:java正则表达式单引号 编辑:程序博客网 时间:2024/04/30 20:12

DateTime dt = DateTime.Now;

dt.GetDateTimeFormats('s')[0].ToString();  //2011-03-21T13:04:09

dt.GetDateTimeFormats('t')[0].ToString();  //13:04

dt.GetDateTimeFormats('y')[0].ToString(); //2011年3月
dt.GetDateTimeFormats('D')[0].ToString(); //2011年3月17日
dt.GetDateTimeFormats('D')[1].ToString(); //2011 3 17
dt.GetDateTimeFormats('D')[2].ToString(); // 2011 17 05 星期四
dt.GetDateTimeFormats('D')[3].ToString(); // 2011年3月7日 星期四
dt.GetDateTimeFormats('M')[0].ToString(); //3月17日
dt.GetDateTimeFormats('f')[0].ToString();  //2011年3月17日 12:12
dt.GetDateTimeFormats('g')[0].ToString(); //2011-3-17 12:12
dt.GetDateTimeFormats('r')[0].ToString(); //Mon, 21 Mar 2011 13:04:09 GMT