coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

date conversion from locale-specific format to any other date-format


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

Hello, 
I have had a problem when it comes to converting date formats. Originally, I posted my question on stackexchange (http://stackoverflow.com/questions/14220636/how-to-convert-a-custom-date-format-to-an-alternate-format-with-the-gnu-date-c), but I would like to ask your thoughts. The following is not a reposting of the stackexchange question.

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]