简体   繁体   English

如何使用 shell 脚本在 linux/centos/rhel 中以毫秒为单位转换任何日期格式

[英]How to convert any date format in milliseonds in linux/centos/rhel with shell script

How to convert any date format in milliseonds in linux/centos/rhel with shell script如何使用 shell 脚本在 linux/centos/rhel 中以毫秒为单位转换任何日期格式

Date formats like: Thu, 23 Jun 2022 08:27:26 +0000, Thu Jun 23 11:11:43 UTC 2022, 2022-06-23T08:28:23Z日期格式,例如:2022 年 6 月 23 日星期四 08:27:26 +0000、2022 年 6 月 23 日星期四 11:11:43 UTC 2022、2022-06-23T08:28:23Z

This can be converted in milliseconds with command:这可以用命令在毫秒内转换:

date -d "2022-06-23T08:28:23Z" +"%s%N"

Any other format of date can also be converted with above command like:任何其他格式的日期也可以使用上述命令进行转换,例如:

date -d "Thu, 23 Jun 2022 08:27:26 +0000" +"%s%N"
date -d "Thu Jun 23 11:11:43 UTC 2022" +"%s%N"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM