.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 ...
随机推荐
- Linux企业运维高效技巧心得及分享
本博文出自51CTO博主 吴光科 的博客,有任何问题请进入博主页面互动讨论! 博文地址:http://wgkgood.blog.51cto.com/1192594/1641247 随着Linux在企业 ...
- KEIL MDK 5.12帮你快速建工程模板的技巧
KEIL 5帮你快速建工程模板的技巧 本人使用keil mdk 5.12有一段时间了,发现keil mdk 5.12里面驱动库比较方便.这个新功能可以节省我们的时间,也可以让初学者能尽快上手和掌握这个 ...
- 【leetcode❤python】24. Swap Nodes in Pairs
#-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init ...
- 【leetcode❤python】217. Contains Duplicate
#-*- coding: UTF-8 -*- class Solution(object): def containsDuplicate(self, nums): numsdic= ...
- 不小心删除数据--利用MySQL的binlog恢复数据
MySQL Binary Log也就是常说的bin-log, ,是mysql执行改动产生的二进制日志文件,其主要作用有两个: * 数据回复 * 主从数据库.用于slave端执行增删改,保持与maste ...
- [POJ2182]Lost Cows(树状数组,二分)
题目链接:http://poj.org/problem?id=2182 题意:给定1~n个数和n个位置,已知ai表示第i个位置前有ai个数比当前位置的数小,求这个排列. 和刚才YY的题意蛮接近的,用树 ...
- [C和指针]第四部分
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- StopWatch的使用
//StopWatch在System.Diagnostics命名控件,要使用它就要先引用这个命名空间. //其使用方法如下: //var stopWatch = new StopWatch(); // ...
- 3----lua的数据转换及运算符
lua的基本数据类型转换 转换成字符串 tostring( ... ) 可以将布尔类型和数字类型的值转换为字符串类型的值 local num=1; print(type(num)) newNum = ...
- JavaWEB 常用开发模式MVC+三层结构
MVC开发模式: M: Model -- JavaBean C: Controler -- Servlet V: View --- JSP 不会在word里面画画,所以就直接截了 老 ...