时间戳定义为从格林威治时间 1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数。

C#格式时间转时间戳Timestamp

private int GetCreatetime()  {

DateTime DateStart= new DateTime(1970,1,1,8,0,0);

return Convert.ToInt32((DateTime.Now - DateStart).TotalSeconds);

}

时间戳转为C#格式时间

private DateTime GetTime(string timeStamp)  {

           DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); 
           long lTime = long.Parse(timeStamp + "");
  • TimeSpan toNow = new TimeSpan(lTime); return dtStart.Add(toNow);
  • }  

C# 时间戳和时间的相互转换的更多相关文章

  1. JavaScript中时间戳和时间的相互转换

    时间转换成时间戳: var time = new Date(); var timestamp=Date.parse(time)   //毫秒数,得到秒除以1000: 时间戳转成时间: 1.转换成 20 ...

  2. python正常时间和unix时间戳时间的相互转换源码

    在学习过程,将内容过程比较常用的一些内容做个珍藏,下面的内容段是关于python正常时间和unix时间戳时间的相互转换的内容,应该是对各朋友有些帮助. import time def timestam ...

  3. JS时间戳与时间字符串之间的相互转换

    时间字符串 转 时间戳 /** * 时间字符串 转 时间戳 * @param {String} time_str 时间字符串(格式"2014-07-10 10:21:12") * ...

  4. (转)golang获取当前时间、时间戳和时间字符串及它们之间的相互转换

    原文连接: https://blog.csdn.net/skh2015java/article/details/70051512 1.获取当前时间 currentTime:=time.Now() // ...

  5. jQuery中时间戳和日期的相互转换

    在项目中经常会使用时间戳和日期的相互转换,可以参考如下代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 2 ...

  6. UNIX时间戳与日期的相互转换

    mysql中UNIX时间戳与日期的相互转换 UNIX时间戳转换为日期用函数:FROM_UNIXTIME() select FROM_UNIXTIME(1410318106); 日期转换为UNIX时间戳 ...

  7. Python时间戳和日期的相互转换

    Python时间戳和日期的相互转换 (2014-03-17 11:24:35) 转载▼   分类: Python 当前时间戳:time.time() 当前日期:time.ctime() 1.Pytho ...

  8. mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间

    mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间,我们在mysql里面他封装了一个内置的时间戳转化的函数,比如我们现在的时间戳是:1458536709 ,"%Y-%m-%d&quo ...

  9. MySQL时间戳和时间格式转换函数

    MySQL时间戳和时间格式转换函数:unix_timestamp and from_unixtime unix_timestamp将时间转化成时间戳格式.from_unixtime将时间戳转化成时间格 ...

随机推荐

  1. Hibernate SQL方言 (hibernate.dialect)

    数据库 hibernate方言 DB2 org.hibernate.dialect.DB2Dialect DB2 AS/400 org.hibernate.dialect.DB2400Dialect ...

  2. phonegap上传以及下载图片

    在phonegap中,有时我们需要从服务器下载图片以及上传图片,这个时候可以用到官方提供的一个插件:FileTransfer 首先通过命令添加插件: cordova plugin add org.ap ...

  3. Hadoop伪分布模式配置

    本作品由Man_华创作,采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可.基于http://www.cnblogs.com/manhua/上的作品创作. 请先按照上一篇文章H ...

  4. 扫描二维码跳转app

    1.判断是否安装了app <html> <head> <meta name="viewport" content="width=device ...

  5. ASP.NET 大文件上传的简单处理

    在 ASP.NET 开发的过程中,文件上传往往使用自带的 FileUpload 控件,可是用过的人都知道,这个控件的局限性十分大,最大的问题就在于上传大文件时让开发者尤为的头疼,而且,上传时无法方便的 ...

  6. 11gR2数据库日志报错:Fatal NI connect error 12170、

    11gR2数据库日志报错:Fatal NI connect error 12170.TNS-12535.TNS-00505 [问题点数:100分,结帖人MarkIII]             不显示 ...

  7. Find the smallest number whose digits multiply to a given number n

    Given a number ‘n’, find the smallest number ‘p’ such that if we multiply all digits of ‘p’, we get ...

  8. Spinner学习

    我暂且把Spinner称作下拉选择框吧,先来看一下它的效果: 在layout文件中添加Spinner的代码如下: <Spinner android:id="@+id/planets_s ...

  9. spring_150803_component

    实体类: package com.spring.model; public class DogPet { private int id; private String name; private in ...

  10. lintcode:颜色分类

    颜色分类 给定一个包含红,白,蓝且长度为 n 的数组,将数组元素进行分类使相同颜色的元素相邻,并按照红.白.蓝的顺序进行排序. 我们可以使用整数 0,1 和 2 分别代表红,白,蓝. 样例 给你数组  ...