Excel VBA : Convert a date string to a Unix timestamp

标签 excel vba date timestamp

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

最佳答案

日期到时间戳:

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

迄今为止的时间戳:

Public Function fromUnix(ts) As Date
    fromUnix = DateAdd("s", ts, "1/1/1970")
End Function

关于Excel VBA : Convert a date string to a Unix timestamp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12325948/

相关文章:

excel - 将子程序中的两个结果传递给另一个子程序

c# - 确定日期是否为 "work day off"

python - 从 Outlook 电子邮件写入 Excel 文件

excel - 日期时间转换

c# - OpenXML Spreadsheet : Excel gives an error, 然后修复它并且它可以工作。 (C#)

vba - 如何在打开时自动运行多个 VBA 宏

Vba - 为什么 xlHistogram 不起作用?

php - Laravel 5.2+ 日期前后日期验证不起作用

mysql - 如果我有过去的日期和我想要日期之后的月数,如何获得 future 的日期?

.net - 在 x64 系统上的 .NET 中打开 Excel 电子表格