Excel VBA:将日期字符串转换为Unix时间戳

时间:2022-05-06 22:02:25

Excel VBA: How to convert date string
"2012-08-20" to timestamp: 1345438800
I need to store 1345438800 in cell as long data type value.

Excel VBA:如何将日期字符串“2012-08-20”转换为时间戳:1345438800我需要在单元格中存储1345438800作为长数据类型值。

1 个解决方案

#1


27  

Public Function toUnix(dt) As Long
    toUnix = DateDiff("s", "1/1/1970", dt)
End Function

#1


27  

Public Function toUnix(dt) As Long
    toUnix = DateDiff("s", "1/1/1970", dt)
End Function