欧美时间转换

        #region 时间转换
        /// 
        /// 时间转换
        /// 
        /// 日期格式 Jul 24 2014  8:28:03:506AM
        /// 
        public DateTime CovnertTime(string time)
        {
            try
            {
                CultureInfo infoCulture = CultureInfo.CreateSpecificCulture("en-US");
                string format = "MMM dd yyyy h:mm:ss:ffftt";
                DateTime dt = DateTime.ParseExact(time, format, infoCulture);
                return DateTime.ParseExact(dt.ToString("dd-MM-yyyy HH:mm:ss"), "dd-MM-yyyy HH:mm:ss", null);
            }
            catch (Exception ex)
            {
                CultureInfo infoCulture = CultureInfo.CreateSpecificCulture("en-US");
                string format = "MMM dd yyyy  h:mm:ss:ffftt";
                DateTime dt = DateTime.ParseExact(time, format, infoCulture);
                return DateTime.ParseExact(dt.ToString("dd-MM-yyyy HH:mm:ss"), "dd-MM-yyyy HH:mm:ss", null);
            }
        }
        #endregion

你可能感兴趣的:(ASP.Net)