Technology consulting for creative industries

Unix date conversion for ISO compliance

Unix date conversion for ISO compliance

By on Feb 29, 2012 in Apple, Corbell Consulting, Linux, News | 0 comments

So simple and so useful. If you have a lot of data with ‘unusual’ date stamps, you can easily convert them to ISO compliant Calendar Date format using the built in UNIX date command.

-j tells the system not to try to set the date, but to look for input from the -f flag
-f denotes that you’re going to specify the input format of the date you’re trying to convert

Then you need to describe the input format. The Wikipedia page on the the UNIX date command has all of the details on the different representations of year, month, day, weeks, etc.

Here are some samples:

date -jf “%m_%d_%y” 2_29_12 “+%Y-%m-%d”

date -jf “%y%m%d” 120402 “+%Y-%m-%d”

date -jf “%y/%m/%d” 12/4/2 “+%Y-%m-%d”

date -jf “%m_%d_%y” 2_29_12 “+%Y-%m-%d”

Post a Reply

Your email address will not be published. Required fields are marked *