DateTime时间格式转换为Unix时间戳格式
/// <summary>
/// 将DateTime时间格式转换为Unix时间戳格式
/// </summary>
/// <param name="dateTime">DateTime时间</param>
/// <param name="format">精度:Seconds-秒,Milliseconds-毫秒</param>
/// <returns></returns>
public static long ToUnixTimeStamp(this DateTime dateTime, string accuracy)
{
long intResult = ;
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(, , ));
switch (accuracy)
{
case "Seconds":
intResult = (long)(dateTime - startTime).TotalSeconds;
break;
case "Milliseconds":
intResult = (long)(dateTime - startTime).TotalMilliseconds;
break;
default:
intResult = (long)(dateTime - startTime).TotalSeconds;
break;
} return intResult;
}
DateTime时间格式转换为Unix时间戳格式的更多相关文章
- C# DateTime时间格式转换为Unix时间戳格式
double ntime=dateTimeToUnixTimestamp(DateTime.Now); long g1 = GetUnixTimestamp(); long g2 = ConvertD ...
- [工具类]将时间转换为unix时间戳格式
写在前面 由于在数据库中存的时间有时间戳格式的数据,在解析以及保存的时候,就需要考虑到数据格式的兼容性问题.看到数据库中的时间字段基本上都是以时间戳格式存储的,没办法,只能将时间进行转换了,考虑到其他 ...
- c# dateTime格式转换为Unix时间戳工具类
using System; using System.Collections.Generic; using System.Text; namespace TJCFinanceWriteOff.BizL ...
- c# datetime与 timeStamp(unix时间戳) 互相转换
/// <summary> /// Unix时间戳转为C#格式时间 /// </summary> /// <param name="timeStamp" ...
- c# DateTime时间格式和JAVA时间戳格式相互转换
/// java时间戳格式时间戳转为C#格式时间 public static DateTime GetTime(long timeStamp) { DateTime dtStart = TimeZon ...
- MySql 格式化时间(包括正常时间格式与unix时间戳的互相转换)
函数:FROM_UNIXTIME 作用:将MYSQL中以INT(11)存储的时间以"YYYY-MM-DD"格式来显示.语法:FROM_UNIXTIME(unix_timestamp ...
- 将windows文本格式转换为UNIX格式
将windows文本格式转换为UNIX格式 1.使用sed命令来进行转换,如下: sed -e ’s,^M,,g’ textfile 其中^M的输入方法是Ctrl+V, Ctrl+M 对于批量文件的处 ...
- Jquery实现日期转换为 Unix时间戳及时间戳转换日期
(function ($) { $.extend({ myTime: { /** * 当前时间戳 * @return <int> unix时间戳(秒) */ CurTime: functi ...
- Swagger--解决日期格式显示为Unix时间戳格式 UTC格式
在swagger UI模型架构上,字段日期显示为“日期”:“2018-10-15T09:10:47.507Z”但我需要将其作为“日期”:“2018-9-26 12:18:48”. tips:以下这两种 ...
随机推荐
- JDK8中的并行流
1.IntStream.parallel():获取并行流处理 2. Collection中调用parallelStream()获取并行流 3.并行排序Arrays.parallelSort()
- spring activemq 整合
创建maven项目 项目目录结构为 首先配置相关maven依赖 <!-- 版本管理 --> <properties> <springframework>4.1.8. ...
- 每个Java程序员需要了解的8个Java开发工具
每个Java程序员需要了解的8个Java开发工具 Java是计算机应用程序编程语言,被广泛用于创建Web应用.服务器处理.用户端的API开发乃至数据库等多个领域.下面列出了8个有助于你开发Java应用 ...
- [FWT] UOJ #310. 【UNR #2】黎明前的巧克力
[uoj#310][UNR #2]黎明前的巧克力 FWT - GXZlegend - 博客园 f[i][xor],考虑优化暴力,暴力就是FWT xor一个多项式 整体处理 (以下FWT代表第一步) F ...
- A1120. Friend Numbers
Two integers are called "friend numbers" if they share the same sum of their digits, and t ...
- 在views中引用UserProfile报错RuntimeError: Model class apps.users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
如图报错,在settings中,该加的也加了啊! 显然类似于网上最容易遇到的解决方案如下图,是没有任何意义的 只要在view中有 from .models import UserProfile,Ver ...
- Day5--Python--字典
字典1.什么是字典 dict. 以{}表示,每一项用逗号隔开,内部元素用key:value的形式来保存数据 {'jj':'林俊杰','jay':'周杰伦'} 查询效率非常高,通过key来查找元素 内部 ...
- Android studio自带的sample例子
1. 直接查看Github上面的Sample Sample in GitHub: 点击打开链接 2. FQ下载(个人倾向于下载) 需要FQ工具 goagent goagent在windows下的安装 ...
- (基础)codeVs2235 机票打折
题目描述 Description .输入机票原价(3到4位的正整数,单位:元),再输入机票打折率(小数点后最多一位数字).编程计算打折后机票的实际价格(单位:元.计算结果要将个位数四舍五入到十位数“元 ...
- (count 或直接枚举) 统计字符 hdu1860
统计字符(很水) 链接:http://acm.hdu.edu.cn/showproblem.php?pid=1860 Time Limit: 1000/1000 MS (Java/Others) ...