zoukankan      html  css  js  c++  java
  • [转载]vb 时间戳与时间互转

    转自:https://blog.csdn.net/boys1999/article/details/23298415

    vb 时间戳与时间互转

    在线测试时间戳与时间:http://tool.chinaz.com/Tools/unixtime.aspx

    '参数:strTime:要转换的时间;intTimeZone:该时间对应的时区
    '返回值:strTime相对于1970年1月1日午夜0点经过的秒数
    '示例:ToUnixTime("2008-5-23 10:51:0", +8),返回值为1211511060
    Function ToUnixTime(strTime, intTimeZone)
    If IsEmpty(strTime) Or Not IsDate(strTime) Then strTime = Now
    If IsEmpty(intTimeZone) Or Not IsNumeric(intTimeZone) Then intTimeZone = 0
    ToUnixTime = DateAdd("h", -intTimeZone, strTime)
    ToUnixTime = DateDiff("s", "1970-1-1 0:0:0", ToUnixTime)
    End Function

    '把UNIX时间戳转换为标准时间
    '参数:intTime:要转换的UNIX时间戳;intTimeZone:该时间戳对应的时区
    '返回值:intTime所代表的标准时间
    '示例:FromUnixTime("1211511060", +8),返回值2008-5-23 10:51:0
    Function FromUnixTime(intTime, intTimeZone)
    If IsEmpty(intTime) Or Not IsNumeric(intTime) Then
    FromUnixTime = Now()
    Exit Function
    End If
    If IsEmpty(intTime) Or Not IsNumeric(intTimeZone) Then intTimeZone = 0
    FromUnixTime = DateAdd("s", intTime, "1970-1-1 0:0:0")
    FromUnixTime = DateAdd("h", intTimeZone, FromUnixTime)
    End Function
    ---------------------
    作者:boys1999
    来源:CSDN
    原文:https://blog.csdn.net/boys1999/article/details/23298415
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    hping3 DDOS泛洪攻击
    如何利用kali破解密码
    python 字典数据类型day05
    Cisco Packet Tracer思科模拟器汉化本
    菜鸟入坑pythonday04列表
    python菜鸟入坑day02
    python运行的第一个脚本菜鸟篇
    python整个安装过程+环境变量
    菜鸟入坑python第一节
    01、python基础知识
  • 原文地址:https://www.cnblogs.com/workingdiary/p/10607961.html
Copyright © 2011-2022 走看看