时间戳与时间相互转换(php .net精确到毫秒)

2019-12-26 13:29:58王振洲
  • }  catch (Exception ex) 
  • {  return start;//转换失败 
  • }  return time; 
  • }  /// <summary> 
  • /// DateTime转换为Unix时间戳  /// </summary> 
  • /// <param name="time"></param>  /// <returns></returns> 
  • private string ConvertTimestamp(DateTime time)  { 
  • double intResult = ;  System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(, , )); 
  • intResult = (time - startTime).TotalMilliseconds;  return Math.Round(intResult,).ToString();