.net 时间戳和日期互转 【转】http://www.cnblogs.com/zhuiyi/p/5307540.html
.net 时间戳和日期互转
1、时间戳转日期
public static DateTime IntToDateTime(int timestamp)
{
return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970,1,1)).AddSeconds(timestamp);
}
调用:IntToDateTime(1458637638);
输出:2016/3/22 17:7:18
2、日期转时间戳
public static DateTime DateTimeToInt(DateTime datetime)
{
return (datetime.ToUniversalTime().Ticks - new DateTime(1970, 1, 1).Ticks) / 10000000
}
调用: DateTimeToInt(DateTime.Now);
输出:1458638060
.net 时间戳和日期互转 【转】http://www.cnblogs.com/zhuiyi/p/5307540.html的更多相关文章
- .net 时间戳和日期互转
1.时间戳转日期 public static DateTime IntToDateTime(int timestamp) { ,,)).AddSeconds(timestamp); } 调用: ...
- PHP时间戳和日期互转换
在php中我们要把时间戳转换日期可以直接使用date函数来实现,如果要把日期转换成时间戳可以使用strtotime()函数实现,下面我来给大家举例说明. 1.php中时间转换函数 strtotime ...
- MySQL时间戳与日期互转
1.UNIX时间戳转换为日期用函数: FROM_UNIXTIME() ); 输出:2006-08-22 12:11:10 2.日期转换为UNIX时间戳用函数: UNIX_TIMESTAMP() sel ...
- js 时间戳和日期互转
// 获取当前时间戳(以s为单位) var timestamp = Date.parse(new Date()); timestamp = timestamp / 1000; //当前时间戳为:140 ...
- Python时间戳和日期的相互转换
Python时间戳和日期的相互转换 (2014-03-17 11:24:35) 转载▼ 分类: Python 当前时间戳:time.time() 当前日期:time.ctime() 1.Pytho ...
- php 时间戳与日期的转换(转载)
UNIX时间戳和格式化日期是我们常打交道的两个时间表示形式. a:Unix时间戳存储.处理方便,但是不直观 b:格式化日期直观,但是处理起来不如Unix时间戳那么自如 [关于两者的互相转换] 日 期 ...
- jquery 时间戳与日期转换
(function($) { $.extend({ myTime: { /** * 当前时间戳 * @return <int> unix时间戳(秒) */ CurTime: functio ...
- java 日期转时间戳,时间戳转为日期
package date; import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Dat ...
- 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 ...
随机推荐
- WINCE6.0组件选择说明
WINCE6.0组件选择说明 图1 RAS/PPP组件前面的√标识表示我们手动选择,TAPI2.0前面的■标识表示选组件时根据依赖关系自动选择的,PPPoE前面的□标识组件没有选择.
- 【转载】ogre内存管理
原文:ogre内存管理 OGRE内存分配策略相关文件及简述 OGRE提供了自己的内存分配策略,甚至为STL容器提供了新的分配策略,相关文件及简述如下: OgreMemoryAllocatedObjec ...
- 各种编码中汉字所占字节数;中文字符集编码Unicode ,gb2312 , cp936 ,GBK,GB18030
vim settings set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936,latin1set termencoding=utf-8se ...
- 如何查看postfix的版本
[root@localhost sasl2]# postconf -d | grep mail_versionmail_version = 2.10.1milter_macro_v = $mail_n ...
- Have You Ever Wondered About the Difference Between NOT NULL and DEFAULT?
https://blog.jooq.org/2014/11/11/have-you-ever-wondered-about-the-difference-between-not-null-and-de ...
- sequenza细胞纯度计算
安装sequenza bam文件要放在前面,否侧会-f命令可能识别错误 samtools mpileup a.bam -f hg19.fasta -Q 20 |gzip > normal.pil ...
- STORM_0001_用vmware拷贝出三个相同的ubuntu搭建小的zookeeper集群
第一次配置zookeeper的集群 因为想运行storm必须搭建集群在自己的电脑上拷贝了自己的ubuntu虚拟机采用的是vmware给虚拟机分配的地址三个机器的配置基本上一样除了myid这个文件看了这 ...
- Maven聚合与继承
分别为两种不同形式的聚合 相关代码如下: https://github.com/humeng126/account-parent_1 https://github.com/humeng126/acco ...
- poj2986A Triangle and a Circle&&poj3675Telescope(三角形剖分)
链接 2986是3675的简化版,只有一个三角形. 这题主要在于求剖分后三角形与圆的相交面积,需要分情况讨论. 具体可以看此博客 http://hi.baidu.com/billdu/item/703 ...
- poj1755Triathlon(半平面交)
链接 根据题意可以设三段路程分别为A,B,C 那么总时间t = A/V+B/U+C/W. 这样根据时间大小关系可以跟其余n-1个联立形成n-1个方程. 化简后为A(1/vj-1/vi)+B(1/uj- ...