/// <summary>
/// 时间戳转成时间类型
/// </summary>
/// <param name="timeStamp"></param>
/// <returns></returns>
public static DateTime GetTime(string timeStamp)
{
DateTime dtStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
return dtStart.Add(toNow);
} /// <summary>
/// 时间类型转成long
/// </summary>
/// <param name="time"></param>
/// <returns></returns>
public static long ConvertDateTimeInt(System.DateTime time)
{
long intResult = 0;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
intResult = (long)(time - startTime).TotalSeconds;
return intResult;
}
/// <summary>
/// 拼接json的字符串;
/// 比如:"{\"ret\":\"err\",\"stadname\":\"未知\"}"
/// </summary>
/// <param name="jsonDict"></param>
/// <returns></returns>
public static string getJsonStr(Dictionary<string, string> jsonDict)
{
StringBuilder sb = new StringBuilder("{");
int i = 0;
foreach (KeyValuePair<string, string> jd in jsonDict)
{
if (i != (jsonDict.Count() - 1))
{
sb.Append("\"" + jd.Key + "\":\"" + jd.Value + "\",");
}
else
{
sb.Append("\"" + jd.Key + "\":\"" + jd.Value + "\"");
} i++;
} sb.Append("}");
return sb.ToString();
}

Asp.Net时间戳与时间互转的更多相关文章

  1. [转载]vb 时间戳与时间互转

    转自:https://blog.csdn.net/boys1999/article/details/23298415 vb 时间戳与时间互转 2014年04月09日 21:13:47 boys1999 ...

  2. lua 时间戳和时间互转

    1.时间戳转换成时间 local t = 1412753621000 function getTimeStamp(t)     return os.date("%Y%m%d%H", ...

  3. C#时间戳与时间互转

    /// <summary> /// 时间戳转成时间类型 /// </summary> /// <param name="timeStamp">& ...

  4. js 时间戳转时间工具类 js时间戳与时间互转

    /** * 时间戳格式化函数 * @param {string} format 格式 * @param {int} timestamp 要格式化的时间 默认为当前时间 * @return {strin ...

  5. python(6)时间戳和北京时间互转,输出当前的时间和推到七天前的日期

    项目发展的需要:(包含时间函数)time datetime 时间戳和北京时间互转 import time import datetime s = '2015-04-17 11:25:30' d = d ...

  6. mysql时间操作(时间差和时间戳和时间字符串的互转)

    mysql时间操作(时间差和时间戳和时间字符串的互转) 两个时间差: MySQL datediff(date1,date2):两个日期相减 date1 - date2,返回天数. select dat ...

  7. JS时间戳和时间之间转换

    一.时间转换时间戳 var date = new Date(); //时间对象 var str = date.getTime(); //转换成时间戳 二.时间戳转换为时间 1.转换成形如 ‎2018‎ ...

  8. 时间戳(Unix时间)

    /// <summary> /// 时间戳与DateTime互转 /// </summary> public class UnixOfTimeHelper { /// < ...

  9. mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间

    mysql取出现在的时间戳和时间时间戳转成人类看得懂的时间,我们在mysql里面他封装了一个内置的时间戳转化的函数,比如我们现在的时间戳是:1458536709 ,"%Y-%m-%d&quo ...

随机推荐

  1. 第五周技术博客发表 web 网页开发

    <html><head> <title> HTML</title></head><body > <h1>会员注册界面 ...

  2. 把工程部署在tomcat的root路径下

    myeclipse可以右键工程:(eclipse也可以)选择properties->myeclipse->web:把web context-root改成:/然后在用myeclipse部署项 ...

  3. 【HDOJ】【1693】Eat The Trees

    插头DP 插头dp模板题…… 这题比CDQ论文上的例题还要简单……因为不用区分左右插头(这题可以多回路,并不是一条哈密尔顿路) 硬枚举当前位置的状态就好了>_< 题解:http://blo ...

  4. 2013 Asia Hangzhou Regional Contest

    Lights Against Dudely http://acm.hdu.edu.cn/showproblem.php?pid=4770 15个位置,所以可以暴力枚举那些放,对于放的再暴力枚举哪个转, ...

  5. struts.properties配置详解(转)

    Struts 2框架有两个核心配置文件,其中struts.xml文件主要负责管理应用中的Action映射,以及该Action包含的Result定义等.除此之 外,Struts 2框架还包含     s ...

  6. uva 10859

    刘书例题  树形dp #include <cstdio> #include <cstdlib> #include <cmath> #include <map& ...

  7. Eclipse改变外观,护眼模式

    1.Eclipse改变背景颜色 Windows menu --> Preference General -> Editors -> Text Editors(click),  在右下 ...

  8. Proxmox虚拟机增加硬盘容量

    1.首先在虚拟机控制台选择调整硬盘容量,弹出窗口为增加的容量 2.重启虚拟机,用fdisk –l查看新增容量是否被识别 3.用cfdisk创建分区,分区格式为Primary 8e (Linux LVM ...

  9. StringBuffer 和 StringBuilder

    如果你读过<Think in Java>,而且对里面描述HashTable和HashMap区别的那部分章节比较熟悉的话,你一定也明白了原因所在.对,就是支持线程同步保证线程安全而导致性能下 ...

  10. C Primer Plus之C预处理器和C库

    编译程序前,先由预处理器检查程序(因此称为预处理器).根据程序中使用的预处理器指令,预处理器用符号缩略语所代表的内容替换程序中的缩略语. 预处理器不能理解C,它一般是接受一些文件并将其转换成其他文本. ...