摘要: 1 /// <summary> 2 /// 本地时间转成GMT时间 3 /// </summary> 4 public static string ToGMTString(DateTime dt) 5 { 6 return dt.ToUniversalTime().ToString("r"); 7 } string s = ToGMTString(DateTime.Now);//本地时间为:2011-9-29 15:04:39//转换后的时间为:Thu, 29 Sep 2011 07:04:39 GMT/// <summary> /// 阅读全文
posted @ 2013-01-14 16:44 一修先生 阅读(6443) 评论(0) 推荐(1) 编辑
摘要: C#中主要用的是DateTime的ToString()方法,该方法有6次重载,这里主要用的是ToString(string format)关于format的说明:格式字符 关联属性/说明 d ShortDatePattern D LongDatePattern f 完整日期和时间(长日期和短时间) F FullDateTimePattern(长日期和长时间) g 常规(短日期和短时间) G 常规(短日期和长时间) m、M MonthDayPattern r、R RFC1123Pattern s 使用当地时间的 SortableDateTimePattern(基于 ISO 86... 阅读全文
posted @ 2013-01-14 16:39 一修先生 阅读(1240) 评论(0) 推荐(0) 编辑