linux将时间(不同时区)转换为UTC [英] linux convert time(for different timezones) to UTC
本文介绍了linux将时间(不同时区)转换为UTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 linux 中有没有办法以编程方式获取给定时间字符串的 UTC 时间,例如
Is there a way, in linux, to programmatically get UTC time for a given time string like
Tue Dec 14 10:30:23 PST 2012
Tue Jan 4 11:30:23 EST 2013
到 UTC 时间,与(且不更改)本地时区设置无关?
to a UTC time, irrespective of( and without changing) local time zone settings?
推荐答案
date -u -d "Tue Dec 14 10:30:23 PST 2012"
报告 Fri Dec 14 18:2012 年 30:23 UTC
.差异是因为 2012 年 12 月 14 日实际上是星期五,而不是星期二.使用有效输入可能效果更好...
date -u -d "Tue Dec 14 10:30:23 PST 2012"
reports Fri Dec 14 18:30:23 UTC 2012
. The discrepancy is because Dec 14 2012 is in fact a Friday, not a Tuesday. It probably works better with valid input...
这篇关于linux将时间(不同时区)转换为UTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文