bash的字符串到日期 [英] bash string to date

查看:181
本文介绍了bash的字符串到日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有字符串转换成在bash约会的机会?例如:我有一个时间格式为:%Y-%M-%德尚%H:%M:%S。这种串的一个例子是2009-06-24S12:34:56。我需要这个字符串转换成在bash日期(UNIX时间戳)。我怎样才能做到这一点?

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?

推荐答案

使用

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

这篇关于bash的字符串到日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆