页首Html代码

返回顶部

VB6之从1970年1月1日起的秒数 的与C语言类似的时间函数

 

程序里 时间一般都用 1970-1-1 到现在的时间了  

Function getSecondsFrom1970() As Long
    '%s  seconds since `00:00:00 1970-01-01 UTC" (a GNU extension)
    getSecondsFrom1970 = DateDiff("s", "1970/01/01", Now())
    '2011/03/02 18:11:24 =>1299089484
    
End Function
Function getDateTimeFromSeconds(ByVal seconds As Long) As String
    getDateTimeFromSeconds = Format(DateAdd("s", seconds, "1970/01/01"), "YYYY/MM/DD HH:mm:ss")
    '1299089484=>2011/03/02 下午 06:11:24
    
End Function

VB6 1970-01-01秒數時間格式轉換 

以前 我老笨了,居然 根据now获得 年月日 小时 分钟 秒,然后再弄个 闰年判断函数,从1970年 计算到现在。。真是弱智到顶了。。。

posted @ 2012-06-20 18:25  ayanmw  阅读(1460)  评论(0编辑  收藏  举报

页脚Html代码