zoukankan      html  css  js  c++  java
  • 时间戳的使用

    一、什么是时间戳

            时间戳, 又叫Unix Stamp. 从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒。

    二、如何计算时间戳

            最常用的Unix时间戳(TimeStamp)是指格林尼治时间1970年1月1日0时(北京时间1970年1月1日8时)起至现在的总秒数(10位)或总毫秒数(13位);

     1 class DateTimeUtil
     2     {
     3         /// <summary>
     4         /// 获取当前时间戳(10位)
     5         /// </summary>
     6         /// <returns></returns>
     7         public static long ShortTimestamp()
     8         {
     9             return new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
    10         }
    11 
    12         /// <summary>
    13         /// 获取当前时间戳(13位)
    14         /// </summary>
    15         /// <returns></returns>
    16         public static long LongTimestamp()
    17         {
    18             return new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
    19         }
    20     }
  • 相关阅读:
    html 简介
    MySQL事务等了解知识
    MySQL—navicat&&练习&&pymysql
    MySQL查询表(一)
    作业
    MySQL约束&&表关系
    mysql数据类型
    初识mysql
    dll 原理解析
    又过了一天
  • 原文地址:https://www.cnblogs.com/dongweian/p/13356084.html
Copyright © 2011-2022 走看看