Jump to content

microtime()


felito

Recommended Posts

felito:

  Is it too hard for you to type in www.php.net/microtime?  Maybe you don't realize that the php manual works that way --- you put in the name of the function you want to read about in the url.  microtime 

 

There is a uniquid function.  That function uses microtime to seed a unique id generation algorithm.

 

 

Also... read the responses to your question.  Xyph took the time to reply to you with an example that answered your question about formatting of a time value.  Did you read it? 

 

 

 

If you want an id, then you are going to get something that has the property of uniqueness.  It is going to be a string, not a date/time value.  Do you want a date/time value or a unique string?

 

 

Link to comment
https://forums.phpfreaks.com/topic/249653-microtime/#findComment-1281583
Share on other sites

PHP implements microtime to help create a pseudo-unique value that has a very low chance of being replicated.

 

Using microtime alone generally isn't enough, as it's predictable.

 

And ideal solution would be to use microtime in combination with things like the users IP and very strong pseudo-random (or random if on a *nix system) data.

 

openssl_random_pseudo_bytes is great, but runs very slow on windows systems and isn't always available to use.

 

Using /dev/random on a *nix system ideal, as it uses environment noise for 'true' random generation.

 

As a worst-case fallback, mt_rand with a combination of the IP and microtime is generally enough, but know mt_rand is considered to be insecure cryptographically.

Link to comment
https://forums.phpfreaks.com/topic/249653-microtime/#findComment-1281586
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.