日期替换

方法1:

 DateTime a = Convert.ToDateTime(Regex.Replace("20130301", @"^(\d{4})(\d{2})(\d{2})$", "$1-$2-$3", RegexOptions.IgnoreCase));

方法2:

 DateTime c = DateTime.ParseExact("20130301", "yyyyMMdd", null);

方法3:

var date = '201403051356236'.replace(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/g,"$1-$2-$3 $4:$5:$6.$7");

 

posted on 2013-04-27 10:21  紫炁星  阅读(251)  评论(0编辑  收藏  举报