bash字符串到目前为止

时间:2009-08-10 09:01:16

标签: bash datetime formatting

是否有机会将字符串转换为bash中的日期?例如:我有时间格式:"%Y-%m-%dS%H:%M:%S"。此类字符串的示例是"2009-06-24S12:34:56"。我需要在bash中将此字符串转换为日期(unix时间戳)。我怎么能这样做?

1 个答案:

答案 0 :(得分:15)

使用

date --utc --date "<input string>" +%s