using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls; public partial class weiapi_ceshi : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(ConvertIntDateTime());
}
/// <summary>
/// 将Unix时间戳转换为DateTime类型时间
/// </summary>
/// <param name="d">double 型数字</param>
/// <returns>DateTime</returns>
public static System.DateTime ConvertIntDateTime(double d)
{
System.DateTime time = System.DateTime.MinValue;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(, , ));
time = startTime.AddMilliseconds(d);
return time;
} /// <summary>
/// 将c# DateTime时间格式转换为Unix时间戳格式,返回格式:1468482273277
/// </summary>
/// <param name="time">时间</param>
/// <returns>long</returns>
public static long ConvertDateTimeInt(System.DateTime time)
{
//double intResult = 0;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(, , , , , , ));
//intResult = (time- startTime).TotalMilliseconds;
long t = (time.Ticks - startTime.Ticks) / ; //除10000调整为13位
return t;
}
}

其他获取当前时间戳

Java

time

JavaScript

Math.round(new Date() / 1000)

.NET / C#

(DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000000

PHP

time()

MySQL

SELECT unix_timestamp(now())

SQL Server

SELECT DATEDIFF(s, '1970-01-01 00:00:00', GETUTCDATE())

SQLite

SELECT strftime('%s', 'now')

PostgreSQL

SELECT extract(epoch FROM now())

Python

先 import time 然后 time.time()

Ruby

获取Unix时间戳:Time.now 或 Time.new显示Unix时间戳:Time.now.to_i

Perl

time

Swift

NSDate().timeIntervalSince1970

Objective-C

[[NSDate date] timeIntervalSince1970]

Erlang

calendar:datetime_to_gregorian_seconds(calendar:universal_time())-719528*24*3600.

Go

import ("time") int32(time.Now().Unix())

Unix / Linux

date +%s

VBScript / ASP

DateDiff("s", "01/01/1970 00:00:00", Now())

Asp.Net Unix时间戳和DateTime类型转换的更多相关文章

  1. C# Unix时间戳和DateTime类型相互转换

    /// <summary> /// 将Unix时间戳转换为DateTime类型时间 /// </summary> /// <param name="d" ...

  2. Unix时间戳与C# DateTime时间类型互换

    Unix时间戳最小单位是秒,开始时间为格林威治标准时间1970-01-01 00:00:00ConvertIntDateTime方法的基本思路是通过获取本地时区表示Unixk开始时间,加上Unix时间 ...

  3. MSSQL中datetime与unix时间戳互转

    //ms sql datetime 转unix时间戳 SELECT DATEDIFF(s, '19700101',GETDATE()) //ms sql unix时间戳 转datetime 涉及到时区 ...

  4. python datetime和unix时间戳之间相互转换

                                python datetime和unix时间戳之间相互转换 1.代码:    import time    import datetime # ...

  5. c#DateTime与unix时间戳互相转换

    public class UnixTimeUtil { /// <summary> /// 将dateTime格式转换为Unix时间戳 /// </summary> /// & ...

  6. c# dateTime格式转换为Unix时间戳工具类

    using System; using System.Collections.Generic; using System.Text; namespace TJCFinanceWriteOff.BizL ...

  7. [开发笔记]-unix时间戳、GMT时间与datetime类型时间之前的转换

    前段时间项目中涉及到了MySql和MsSql数据类型之间的转换,最近又在研究新浪微博的API,涉及到了带有时区的GMT时间类型的转换,所以,特记录于此,以备日后查询. 一:UNIX时间戳与dateti ...

  8. unix时间戳转换成标准时间(c#)

    //---unix时间戳转换成标准时间(c#)---//     /*     string timeStamp = "1144821796";     DateTime dtSt ...

  9. UNIX 时间戳 C#

    /// 将Unix时间戳转换为DateTime类型时间 /// </summary> /// <param name="d">double 型数字</ ...

随机推荐

  1. Query classification; understanding user intent

    http://vervedevelopments.com/Blog/query-classification-understanding-user-intent.html What exactly i ...

  2. execl执行解释器文件以及shell命令

    问题描述:        execl执行解释器文件以及shell命令 问题解决: 具体源文件:

  3. ssh-add 报错 Could not open a connection to your authentication agent

    ERROR: [root@testcentos01 ~]# ssh-add Could not open a connection to your authentication agent 在shel ...

  4. LA 4329

    第一次敲树状数组  因为一个小错误 wa了 n 多遍  终于ac  太不容易了 /*********************************************************** ...

  5. web配置详解

    1.启动一个WEB项目的时候,WEB容器会去读取它的配置文件web.xml,读取<listener>和<context-param>两个结点. 2.紧急着,容创建一个Servl ...

  6. 1009-2的N次方

    描述 编程精确计算2的N次方.(N是介于100和1000之间的整数). 输入 正整数N (100≤N≤1000) 输出 2的N次方 样例输入 200 样例输出 16069380442589902755 ...

  7. [转]Openstack Havana Dashboard测试和使用

    转贴一篇陈沙克老师的文章:http://www.chenshake.com/openstack-havana-dashboard-to-test-and-use/ Openstack Havana D ...

  8. Sina App Engine(SAE)入门教程(2)-Mysql使用

    如果你还没有SAE的账号,请在http://sae.sina.com.cn 注册新用户.具体的注册流程请参见:Sina App Engine(SAE)入门教程(1)在常规的环境下,我们可以通过http ...

  9. python os.stat() 和 stat模块详解

    stat 系统调用时用来返回相关文件的系统状态信息的. 首先我们看一下stat中有哪些属性: >>> import os >>> print os.stat(&qu ...

  10. 基于QT的换肤整体解决方案(QSkinStyle)(提供Linux的XP风格)

    基于QT的换肤整体解决方案(QSkinStyle) 对QT这个成功的跨平台GUI库,本身内置了对换肤功能的实现,比如cleanlooks.plastique等跨平台风格:还有一些是和平台相关的风格,比 ...