微信的CreateTime:DateTime.Now.DateTimeToInt()
来源:互联网 发布:苹果平板淘宝不能横屏 编辑:程序博客网 时间:2024/05/17 03:32
wuhuacong(伍华聪)的专栏里面的系列稳占“C#开发微信门户及应用”中用到了一个DateTimeToInt方法,创建微信消息的CreateTime,这是DateTime的一个扩展方法:
public static class DateTimeUtil
{
/// <summary>
/// 微信的CreateTime是当前与1970-01-01 00:00:00之间的秒数
/// </summary>
/// <param name=“dt”></param>
/// <returns></returns>
public static string DateTimeToInt(this DateTime dt){
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1, 0, 0, 0, 0));
//intResult = (time- startTime).TotalMilliseconds;
long t = (dt.Ticks - startTime.Ticks) / 10000000; //现在是10位,除10000调整为13位
return t.ToString();
}
}
0 0
- 微信的CreateTime:DateTime.Now.DateTimeToInt()
- 微信开发的CreateTime
- DateTime.Now 和DateTime.UtcNow的区别
- DateTime.Now的用法收集
- DateTime.Now
- System.DateTime.Now.ToString()的一些用法
- System.DateTime.Now.ToString()的一些用法
- DateTime.Now.Month返回两位数的方法
- DateTime.Now的相等判断方法
- DateTime.Now不准确的问题
- c#的DateTime.Now函数详解
- c#的DateTime.Now函数详解
- c#的DateTime.Now函数详解
- C#的DateTime.Now函数祥解
- DateTime.Now.ToString()的一些用法
- c#的DateTime.Now函数详解
- c#的DateTime.Now函数详解
- DateTime.Now.ToString() 的一些用法
- Android九宫格 .
- 我的设计模式学习之路二——工厂模式
- android:exported 属性
- DecimalFormat用法
- fedora 下ns2安装完后提示没有xgraph的解决办法
- 微信的CreateTime:DateTime.Now.DateTimeToInt()
- 第五届程序设计大赛 Metric Matrice
- 为PHPStorm配置Xdebug调试环境
- LeetCode OJ 之 Reverse Bits (翻转二进位)
- Android开发 (小属性)积累-------------------设置键盘默认顶起布局
- hdu 2971 Tower(矩阵快速幂)
- 高质量C/C++编程指南(六)
- android学习 -- 读写文件操作
- 深入Java集合学习系列:HashMap的实现原理