Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
144
rated 0 times [  149] [ 5]  / answers: 1 / hits: 18826  / 9 Years ago, fri, september 18, 2015, 12:00:00

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();

More From » javascript

 Answers
6

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).


[#65009] Thursday, September 17, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
koltonadolfow

Total Points: 71
Total Questions: 118
Total Answers: 102

Location: Vietnam
Member since Sun, Oct 18, 2020
4 Years ago
;