C# Unix时间戳和DateTime类型相互转换
/// <summary>
/// 将Unix时间戳转换为DateTime类型时间
/// </summary>
/// <param name="d">double 型数字</param>
/// <returns>DateTime</returns>
public static System.DateTime ConvertIntDateTime(double d)
{
System.DateTime time = System.DateTime.MinValue;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
time = startTime.AddMilliseconds(d);
return time;
} /// <summary>
/// 将c# DateTime时间格式转换为Unix时间戳格式
/// </summary>
/// <param name="time">时间</param>
/// <returns>long</returns>
public static long ConvertDateTimeInt(System.DateTime time)
{
//double intResult = 0;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970,1,1,0,0,0,0));
//intResult = (time- startTime).TotalMilliseconds;
long t = (time.Ticks - startTime.Ticks)/10000; //除10000调整为13位
return t;
}
C# Unix时间戳和DateTime类型相互转换的更多相关文章
- Asp.Net Unix时间戳和DateTime类型转换
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System. ...
- mysql关联修改SQL及long与datetime类型相互转换
1.关联修改 #解决思路 UPDATE tb1,tb2 SET tb1.address=tb2.address WHERE tb1.name=tb2.name UPDATE car c,tmpcolo ...
- SQL 时间戳转DateTime类型
最近在工作中通过接口获取时间字段为时间戳的值,直接入库后再页面查询时间格式时候需要通过SQL语句将时间戳格式装换为时间格式进行比较,首先我们需要知道时间戳格式是怎么产生的,: Unix时间戳(Unix ...
- oracle将unix 时间戳转换为date类型
select to_date('19700101','yyyyMMdd')+numtodsinterval(8*3600,'second')+numtodsinterval(60,'second') ...
- c# 时间戳转换为Datetime类型的时间
private static DateTime GetConvertTime(long ltime) { DateTime dt_time=new DateTime(1970,1,1,8,0,0,0) ...
- Unix时间戳与C# DateTime时间类型互换
Unix时间戳最小单位是秒,开始时间为格林威治标准时间1970-01-01 00:00:00ConvertIntDateTime方法的基本思路是通过获取本地时区表示Unixk开始时间,加上Unix时间 ...
- [开发笔记]-unix时间戳、GMT时间与datetime类型时间之前的转换
前段时间项目中涉及到了MySql和MsSql数据类型之间的转换,最近又在研究新浪微博的API,涉及到了带有时区的GMT时间类型的转换,所以,特记录于此,以备日后查询. 一:UNIX时间戳与dateti ...
- UNIX 时间戳 C#
/// 将Unix时间戳转换为DateTime类型时间 /// </summary> /// <param name="d">double 型数字</ ...
- python datetime和unix时间戳之间相互转换
python datetime和unix时间戳之间相互转换 1.代码: import time import datetime # ...
随机推荐
- Python 中路径的有效使用
import arcpy arcpy.GetCount_management("c:/temp/streams.shp") arcpy.GetCount_management(&q ...
- bing map for wpf 怎么显示中文地图
添加一下代码: string suriFormat = "http://r2.tiles.ditu.live.com/tiles/r{quadkey}.png?g=41"; Mic ...
- VS2015 osgEarth 编译
E:\OpenSourceGraph\CURL_install\includeE:\GDAL\includeE:\Geos\geos_3_5_install\includeE:\OpenSourceG ...
- osg HUD 前景色
#ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include<iostream> #include <osgV ...
- 5G && 物联网
可打电话的 2G.能够上网的 3G.满足移动互联网用户需求的 4G 相比,逐步可以商用的 5G 在多重性能上更胜一筹,如 高数据率: 低延迟: 更节能: 有效地降低通信成本: 具备更高的系统容量: 更 ...
- ABAP编辑器输入中文变成问号
在ABAP编辑器里输入汉字,点击空格后显示问号? 中英文环境下编辑都出现乱码 实用程序->设置 ->基于文本的编辑器 如果用老式编辑器,可以输入中文 试试打个补丁 GUI740 补丁17 ...
- Apache三种工作模式详解
Apache HTTP服务器被设计为一个强大的.灵活的能够在多种平台以及不同环境下工作的服务器.这种模块化的设计就叫做“多进程处理模块”(Multi-Processing Module,MPM),也叫 ...
- php注册自动加载函数
$autoload_func = function($class) { $class = str_replace('\\', '/', $class); $file_name = dirname(__ ...
- WordPress的Bootstrap面包屑导航
<ol class="breadcrumb"> 当前位置: <li><a href="<?php bloginfo('url'); ? ...
- win10 1803 频繁死机,卡死不动
摘自微软官网的解决办法,我的目测好像是可以了. 小娜搜索框输入“PowerShell”选择在管理员命令提示符下键入以下命令: Dism /Online /Cleanup-Image /ScanHeal ...