c#中关于时间转换提供了两种方法:DateTime.ParseExact()和 Convert.ToDateTime(string),ParseExact使用起来会更加灵活,可以由用户自己来定义时间格式,比如数据库里某字段的值都是20071225这种形式,我们可以这样转换:
DateTime time1 = DateTime.ParseExact(dt,"yyyyMMdd", null);
dt为这样的字符串:"20071225
来自:http://www.cn-web.com/shtml/article/net/csharp/2009/02/04/421.shtml