bash string to date

六眼飞鱼酱① 提交于 2019-12-12 08:53:26

问题


Is there an opportunity to convert a string into a date in bash? For example: I have a time format: "%Y-%m-%dS%H:%M:%S". An example of such string is "2009-06-24S12:34:56". I need to convert this string into a date (unix timestamp) in bash. How can I do this?


回答1:


Use

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


来源:https://stackoverflow.com/questions/1253828/bash-string-to-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!