In case you do not need to rely on printable characters, I would suggest, that you simply use the Unix timestamp. That will work great even with 4 Bytes (until January 19, 2038).
If you want to use only a subset of characters, I would suggest, that you create a list of values that you want to use.
- Let's say you want to use the letters (capital and small) and the digits -> 62 values.
- Now you need to convert the timestamp into base-62. Let's say your timestamp is 100:
- 100 = (1 * 62^1) + (38 * 62^0)
- If you have stored your printable value in an array, you could use the coefficients 1 and 38 as an index into that array.
If you chose your base to small, five bytes will not be enough. In that case you can either substract a constant from the timestamp (which will buy you some time) or you can estimate when duplicate timestamps will occur and if that date is past your retirement date ;-)