DateTimeUtils.cs 874 B

12345678910111213141516171819202122232425262728293031323334
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Wit.SDK.Utils
  7. {
  8. /// <summary>
  9. /// 日期工具类
  10. /// </summary>
  11. public class DateTimeUtils
  12. {
  13. /// <summary>
  14. /// 获取时间戳
  15. /// </summary>
  16. /// <returns></returns>
  17. public static long GetTimeStamp()
  18. {
  19. TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
  20. return Convert.ToInt64(ts.TotalMilliseconds);
  21. }
  22. /// <summary>
  23. /// 日期格式化
  24. /// </summary>
  25. /// <param name="dateTime"></param>
  26. /// <param name="format"></param>
  27. /// <returns></returns>
  28. public static string Format(DateTime dateTime, string format) {
  29. return dateTime.ToString(format);
  30. }
  31. }
  32. }