I must generate unique hash - maybe from timestamp. hash must have max 8 chars. How to do it?
For now I have only timestamp:
var t = new Date().getTime();
I must generate unique hash - maybe from timestamp. hash must have max 8 chars. How to do it?
For now I have only timestamp:
var t = new Date().getTime();
That may look funny but the following code may work well for the next couple of centuries :)
(+new Date).toString(36); // "iepii89m"
After that you can extend it with slicing method: (+new Date).toString(36).slice(-8)
.