Technical, Technology

2013-02-27, Indeed!

Okay, I just have to say, Amen, XKCD and ISO!

The correct way to write dates is: 2013-02-27 ...

If you are naming files on a computer, please use this format. The beauty is that if you list files in “alphabetical order” then these dates get listed in chronological order, because as far as a computer is concerned, the “0” comes before “1” and so forth. (And a year is more significant than a month is more significant than a day of the month . . .)

It is important to have that leading zero! Why? Because we have more than 10 months! Allow me to demonstrate:

0-11:32 djh@noneedto ~$ (echo "2013-02-27" && echo "2013-12-27") | sort
0-11:32 djh@noneedto ~$ (echo "2013-2-27" && echo "2013-12-27") | sort

If you are interacting with strftime() then what you want to remember is %F!

0-11:38 djh@noneedto ~$ date +%Y-%m-%d
0-11:38 djh@noneedto ~$ date +%F
0-11:38 djh@noneedto ~$ date +%Y%m%d%H%M # I sometimes use this for file timestamps but dont tell Randall Monroe

For my photographs, I have a directory hierarchy of %Y/%m-%B:

0-11:43 djh@noneedto Photographs$ find . -type d | sort | tail

This gives me the human convenience of seeing the month name on my folders, but the computer sorts those folders in chronological order.

Read More

Categories: Technical, Technology

Discover more from dannyman.toldme.com

Subscribe now to keep reading and get access to the full archive.

Continue reading