|
From: | Derek Ashley Thomas |
Subject: | date conversion from locale-specific format to any other date-format |
Date: | Wed, 9 Jan 2013 08:49:55 +0900 |
I have a string with a custom date format written in Japanese: 2013年1月8日 20時19分
. I wish to convert this string to any other format using date. I expected to use date -d "2013年1月8日 20時19分" +"%F %R" but this produces the wrong date 2013-01-08 20:13 because it sees the 2013 and converts it to hours-minutes (not year) and then forgets the rest and assumes "today". When I updated my machine to 'coreutils 8.20', the same command produces the following error invalid date ‘2013年1月8日 20時19分’. While perhaps the error is best since the date produced originally was wrong, is there any way using the date command to convert from a custom/locale format to any other format? In osx, the date command can be used to specifically convert formats like so:
timestamp="2013年1月8日 20時19分"
date -j -f "%Y年%m月%d日 %H時%M分" "$timestamp" +"%F %R"
Any thoughts or suggestions would be greatly appreciated!
- Derek
[Prev in Thread] | Current Thread | [Next in Thread] |