Development often encounter date conversion problem, especially when doing interface, now collation the next time stamp to C # format time method:
/// <summary> ///time stamp to C # format time/// </summary> /// <param name= "TimeStamp" ></param> /// <returns></returns> Public stringGetTime (stringTimeStamp) { //processing strings, intercepting numbers in parentheses varStrstamp = Regex.Matches (TimeStamp,@"(? <=\ () (? <gp>\ () | (? <-gp>\)) | [^()]+)*(? (GP) (?!))"). Cast<match> (). Select (t = = t.value). ToArray () [0]. ToString (); //processing string Gets the number preceding the + sign varstr = Convert.toint64 (strstamp.substring (0, Strstamp.indexof ("+"))); LongTimetricks =NewDateTime (1970,1,1). Ticks + str *10000+ TimeZone.CurrentTimeZone.GetUtcOffset (datetime.now). Hours *3600* (Long)10000000; return NewDateTime (timetricks). ToString ("YYYY-MM-DD HH:mm:ss"); } /// <summary> ///datetime format conversion to UNIX timestamp format/// </summary> /// <param name= "Time" ></param> /// <returns></returns> Public intConvertdatetimeint (System.DateTime time) {System.DateTime startTime= TimeZone.CurrentTimeZone.ToLocalTime (NewSystem.DateTime (1970,1,1)); return(int) (Time-startTime). TotalSeconds; }
C # \/date (1498820611133+0800) \ Turn datetime