powershell - 使用 UFormat 获取 unix 时间

标签 powershell

我可以使用以下内容将日期附加到文本中:

"Foo {0:G} Foo" -f (date)     #returns "Foo 2009-12-07 15:34:16 Foo"

但我想要 Unix 格式的时间。
我可以通过 date -UFormat %s 得到它,但我可以使用相同的语法吗?

当我使用 -UFormat %s我得到 1260199855,65625,如何去掉小数点?

最佳答案

[int](Get-Date -UFormat %s -Millisecond 0)

关于powershell - 使用 UFormat 获取 unix 时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1860344/

相关文章:

powershell - 在Powershell中比较两个CSV对象

powershell - Powershell过滤输出文件

powershell - 从路径中提取文件名

powershell - 在 powershell 中比较两个哈希表

java - 使用 Powershell 时出现 JDWP 语法错误

json - PowerShell创建嵌套JSON

json - 如何将 XML 分组为 JSON

powershell - 变量类型与 Powershell 中的预期不符

powershell - 如何递归获取PowerShell中自定义输出中所有文件和文件夹的大小

powershell - 如何将 Invoke-SilentlyAndReturnExitCode 实现为 Powershell 模块功能?