shell 获取bash日期,格式为2023-04- 03 T23:59:59.000Z

qqrboqgw  于 2023-04-07  发布在  Shell
关注(0)|答案(1)|浏览(216)

如何获取以下格式的bash日期

2023-04-03T23:59:59.000Z

我试图连接字符串,但它看起来不干净的方法

odopli94

odopli941#

你可以使用下面的date命令:

date -u +"%FT%T.%3NZ"

说明

-u flag tells date to use the UTC timezone
%F specifier is a shorthand for %Y-%m-%d
%T specifier is a shorthand for %H:%M:%S
%3N specifier represents the milliseconds in the current time
Z at the end indicates that the time is in UTC.

相关问题