用CDate函数和Format函数
下面有例子
Dim dblTime As Double
'取得当前时间
dblTime = Now
'格式化显示
MsgBox Format(CDate(dblTime), "yyyy-mm-dd hh:mm:ss")
下面有例子
Dim dblTime As Double
'取得当前时间
dblTime = Now
'格式化显示
MsgBox Format(CDate(dblTime), "yyyy-mm-dd hh:mm:ss")
不对,你的dblTime =Now 的整数,和我的秒计数,不同。我的秒计数算出来有可能是几个月的某一天的日期,我记得在c语言里有一个时间函数可以将相对于1970年1月1日的秒计数换算成为日期,微机是相对于1980年1月1日0分0秒
GetTime = Format(CDate(DateAdd("s", lngTimeAdd, Format("1980-01-01 00:00:00", "yyyy-mm-dd hh:mm:ss"))), "yyyy-mm-dd hh:mm:ss")
End FunctionPrivate Sub Form_Load()
Dim lngTimeAdd As Long
lngTimeAdd = 719080887
Debug.Print GetTime(lngTimeAdd)
End Sub
2002-10-14 16:41:27