- Obviously this cannot be used as a "unique" id because, well, it's not unique during the duration of the same second.
- Look into
date
.
If you want something that is advertised as a unique id and both can be sorted, you can use something like this that involves uniqid
:
$u = time().'-'.uniqid(true);
I 'm perhaps over-simplifying here, taking for granted that all values time
is going to produce will have the same number of digits (so that a string sort would produce the same results as a natural sort). If you don't want to make this assumption, then you could consider
$u = sprintf("%010s-%s", time(), uniqid(true));