Php unique number based on timestamp
I need to generate a unique ID in php based on current date and time to keep a log of when i am running code. i.e. every time i run the code it should be able to generate a unique id based on current date and time. Show Hope I am clear with my ques. How to do that? asked Aug 28, 2012 at 6:33
6 Using time() to create sortable unique id's Concatenating strings will also further randomize your desired result and still keep it sortable. manual here
answered Aug 28, 2012 at 6:42
amitchhajeramitchhajer 12.1k6 gold badges39 silver badges52 bronze badges 0 You can use a combination of
Example output:
answered Aug 28, 2012 at 6:55
Ja͢ckJa͢ck 168k36 gold badges255 silver badges305 bronze badges 1 Is this what you're looking for? uniqid() From the doc: Gets a prefixed unique identifier based on the current time in microseconds. answered Aug 28, 2012 at 6:34
Lucas GreenLucas Green 3,90120 silver badges26 bronze badges 7 View Discussion Improve Article Save Article View Discussion Improve Article Save Article The uniqid() function in PHP is an inbuilt function which is used to generate a unique ID based on the current time in microseconds (micro
time). Syntax: uniqid($prefix, $more_entropy) Parameters Used: The uiqid() function in PHP accepts two parameters.
Return Value: It returns timestamp based unique identifier as a
string.
Below programs illustrate the uniqid() function: phpOutput: 3b2c662647f18 Program 2: php
Output: gfg5b2b451823970 Program 3: php
Output: gfg5b2b4555ab6bd7.27884925 Reference : http://php.net/manual/en/function.uniqid.php |