TimeHelper.cs 475 B

12345678910111213141516171819202122
  1. using System;
  2. namespace Base
  3. {
  4. public static class TimeHelper
  5. {
  6. private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
  7. /// <summary>
  8. /// 客户端时间
  9. /// </summary>
  10. /// <returns></returns>
  11. public static long ClientNow()
  12. {
  13. return Convert.ToInt64((DateTime.UtcNow - Epoch).TotalMilliseconds);
  14. }
  15. public static long ClientNowTicks()
  16. {
  17. return Convert.ToInt64((DateTime.UtcNow - Epoch).Ticks);
  18. }
  19. }
  20. }