Preferred format of file names which include a timestamp

Solution 1:

  1. ISO 8601 format should be adhered to as much as possible, since it is the closest thing there is to a standard.
  2. The 'T' is not enough of a stumbling block to really warrant getting rid of it.
  3. The ':'s are potentially killers, so those should be avoided.
  4. For the reasons mentioned in others' answers, UTC (or 'Z' time) should be used.
  5. ISO 8601 includes a format using UTC ('Z' time), which should be used.
  6. ISO 8601 includes a format that does not use the ':' character, which should be used.

So...sample 'best' date-time formats:

  1. 20120317T1748Z

    • 100% in accordance with ISO 8601
    • alphanumeric characters only (very sysadmin-friendly)
    • not the quickest to read, but certainly readable by the layperson
  2. 2012-03-17T1748Z

    • date portion is in accordance with ISO 8601
    • time portion is in accordance with ISO 8601
    • transition between date and time is in accordance with ISO 8601
    • mixes the ISO 8601 'extended' format (date with hyphens, time with colons) with the ISO 8601 'basic' format (date without hyphens, time without colons), which is likely not quite right
    • adds '-' character (vs 1.)
    • a bit easier for the layperson to read (vs 1.)
  3. 2012-03-17--1748Z

    • date portion is in accordance with ISO 8601
    • time portion is in accordance with ISO 8601
    • transition between date and time is not in accordance with ISO 8601
    • mixes the ISO 8601 'extended' format with the ISO 8601 'basic' format
    • a bit easier for the layperson to read (vs 1. and 2.)
    • no new characters (vs 2.)

I am partial to 1. since it is fully IAW the standard, but the others are close.

Note:: Add seconds as necessary, of course. ...and yes, with or without seconds (or even minutes) is all IAW ISO 8601. :)

Solution 2:

I would not include a time zone, only use universal time. If there may be confusion, you could add a -UTC suffix. If you specify a time zone, someone may depend on it. And there would be weird edge cases where DST changes or DST shifts wreak havoc on some processing, or processing is different on some systems because their DST configuration is not up to date. UTC is always the same everywhere.

I do think that hyphens make the file name more readable, in the sense that it makes it easier to discern the datetime of the file data. If you want to include sub-second precision, that usually is .nnnnn.

I personally don't like the T. Using a colon in a file name may affect interoperability with other file systems.