TimeHelper.cs 513 B

123456789101112131415161718192021222324252627
  1. using System;
  2. namespace ETModel
  3. {
  4. public static class TimeHelper
  5. {
  6. private static readonly long epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks;
  7. /// <summary>
  8. /// 客户端时间
  9. /// </summary>
  10. /// <returns></returns>
  11. public static long ClientNow()
  12. {
  13. return (DateTime.UtcNow.Ticks - epoch) / 10000;
  14. }
  15. public static long ClientNowSeconds()
  16. {
  17. return (DateTime.UtcNow.Ticks - epoch) / 10000000;
  18. }
  19. public static long Now()
  20. {
  21. return ClientNow();
  22. }
  23. }
  24. }