Difference between revisions of "Converting timezone using date command"
From Notes_Wiki
(Created page with "<yambe:breadcrumb>Desktop_tips_and_tricks|Desktop tips and tricks</yambe:breadcrumb> =Converting timezone using date command= To convert time of other timezone to local time ...") |
m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Desktop tips and tricks]] > [[Converting timezone using date command]] | |||
To convert time of other timezone to local time one can use: | To convert time of other timezone to local time one can use: | ||
<pre> | <pre> | ||
date -d ' | date -d '09:30 PDT' | ||
Fri Jul 19 22:00:00 IST 2013 | |||
</pre> | </pre> | ||
Similarly to convert localtime to other timezone we can use: | Similarly to convert localtime to other timezone we can use: | ||
<pre> | <pre> | ||
TZ= | TZ='America/Los_Angeles' date -d '09:30 IST' | ||
Thu Jul 18 21:00:00 PDT 2013 | |||
</pre> | </pre> | ||
Note that: | |||
* Files under /usr/share/zoneinfo can be seen to learn other possible values for TZ | |||
* '''We need to use full name like 'Asia/Seoul' instead of KST to make it work properly as there is no file named KST under /usr/share/zoneinfo'''. However we can use "TZ=EST" as there is file named EST under /usr/share/zoneinfo | |||
Steps learned from http://www.linuxhowtos.org/Tips%20and%20Tricks/timzone_conversion.htm | Steps learned from http://www.linuxhowtos.org/Tips%20and%20Tricks/timzone_conversion.htm | ||
'''More useful help on date command at [[Convert date to different format using date command]]''' | |||
[[Main Page|Home]] > [[CentOS]] > [[CentOS 6.x]] > [[Desktop tips and tricks]] > [[Converting timezone using date command]] |
Latest revision as of 07:55, 15 October 2022
Home > CentOS > CentOS 6.x > Desktop tips and tricks > Converting timezone using date command
To convert time of other timezone to local time one can use:
date -d '09:30 PDT' Fri Jul 19 22:00:00 IST 2013
Similarly to convert localtime to other timezone we can use:
TZ='America/Los_Angeles' date -d '09:30 IST' Thu Jul 18 21:00:00 PDT 2013
Note that:
- Files under /usr/share/zoneinfo can be seen to learn other possible values for TZ
- We need to use full name like 'Asia/Seoul' instead of KST to make it work properly as there is no file named KST under /usr/share/zoneinfo. However we can use "TZ=EST" as there is file named EST under /usr/share/zoneinfo
Steps learned from http://www.linuxhowtos.org/Tips%20and%20Tricks/timzone_conversion.htm
More useful help on date command at Convert date to different format using date command
Home > CentOS > CentOS 6.x > Desktop tips and tricks > Converting timezone using date command