I think what you’re TRYING to do is get the timestamp of midnight in milliseconds and then fill in the zeroes. I still think you’re going about the idea oddly, but sure.

strtotime('today')*1000+rand(10000,99999)

(This effectively generates a random timestamp between midnight and 12:01:39.999, today)

This method will throw you off balance because you will be getting scanty figures
Supposed you want a fixed unique 16 digits this method will give unstable digits and if the value exceeds 32 or so it will return an E+67 kind of count

this method will generate a number exactly 13 digits long for the next 2 and a half centuries (Specifically, until November 19, 2286 at 2:00:00 PM GMT.) After that, it will generate a number that is either 13 or 14 digits long until the next day at 5:46:40 PM, after which it will generate numbers exactly 14 digits long.

the timestamp string is exactly 10 digits long; multiplying it by 1000 adds 3 digits. Adding a number between 10000 and 99999 to this number does not change the length of the number - It’s not APPENDING, it’s ADDING.

In a 64 bit system, PHP’s integer type can store a value equal to 9223372036854775807 - far bigger than the timestamp.

@m_hutley we are all here at sitepoint but you left us here and travel half a century and returned, hope you saw my great, great, great grand kids? Hope they look cute.

I have always known your fingers are gifted in coding, perfectly analogy.

But i rather stick with shuffle to save Apache from doing bytes calculations, and more over shuffle stays till forever but yours has an expiring date.

mine does what the OP asked for. A datetime followed by a random digit 1-9 and 4 random digits 0-9.

I didnt say it was the most random. In fact, I made the statement that there are signifcantly more random random-strings that could be generated.

But it is meaningful. It’s a way of attempting to add entropy to a static timestamp; to avoid a collision (or at least, make the collision condition change from “placed on the same day” to “placed on the same day and 1-in-90000 chance.”

Hi OP, what is the purpose of this? This sounds like an attempted solution to another problem. What is the high level overview of what you have going on?

@m_hutley i know you always try to answer question exactly the way the user asked it and thats professional enough,

But i think at this time the place of strtotime is of no use, getting a time and multiplying and adding rand so whats the place of time stamp? What he needs is a straight random method

Really? Are you sure he doesnt need to be able to tell the time of the order still? Do you have some great mind-reading capability?

At least benanamen asks the OP, rather than inventing his own decision of what the OP wants.

Regardless, the OP’s original question has been answered; if they wish to come back and change their decision of what they want, so be it, but I’m done with this thread.

It is easy enough to answer the question as posted, but experience tells me this is really an XY problem (very common on forums) and is not really what the OP needs an answer too. What we need first is for the OP to tell us what he has going, then we can tell him what he needs to solve the real problem which I am quite sure is not “a unique id made up of a current timestamp”.

So OP, I am still waiting to hear from you with a high level overview of what you are doing and what the real problem is you are trying to solve with your attempted solution to that problem.