/// <summary> /// Convert DateTime To Milliseconds /// </summary> /// <param name="dt">the datetime</param> /// <returns></returns> public static long GetTotalTolMilliseconds(DateTime dt) { string str = new JavaScriptSerializer().Serialize(dt); long result = 0;
str = Regex.Replace(str, @"[^\d.\d]", "");
if (str != null && str != string.Empty) { // clear not number but keep dot str = Regex.Replace(str, @"[^\d.\d]", ""); // if a number if (Regex.IsMatch(str, @"^[+-]?\d*[.]?\d*$")) { result = long.Parse(str); } } return result; }
|
请发表评论