标签: bash datetime formatting
是否有机会将字符串转换为bash中的日期?例如:我有时间格式:"%Y-%m-%dS%H:%M:%S"。此类字符串的示例是"2009-06-24S12:34:56"。我需要在bash中将此字符串转换为日期(unix时间戳)。我怎么能这样做?
"%Y-%m-%dS%H:%M:%S"
"2009-06-24S12:34:56"
答案 0 :(得分:15)
使用
date --utc --date "<input string>" +%s