How to Generate a Unique ID for Order Tracking Numbers

phool4fool

203.***.***.***
1,936 days ago

How to Generate a Unique ID for Order Tracking Numbers

This is a quick little way to generate a unique id for stuff like tracking numbers and order id's using the unix time stamp and the users ip address.

PHP Example:

PHP code:

<?php
$stamp = strtotime("now");
$orderid = $stamp-$REMOTE_ADDR;
$orderid = str_replace(".", "", $orderid);
echo($orderid);
?>

Bradd

203.***.***.***
1,931 days ago

phool4fool;304:

This is a quick little way to generate a unique id for stuff like tracking numbers and order id's using the unix time stamp and the users ip address.

PHP Example:

PHP code:

<?php
$stamp = strtotime("now");
$orderid = "$stamp-$REMOTE_ADDR";
$orderid = str_replace(".", "", $orderid);
echo($orderid);
?>



what is unix time stamp in this code ?
i know about timestamps but is this some unix specified ?

penguinmama

12.***.***.***
1,917 days ago
It's just a basic "current date and time" thing, Bradd. The script generates the current date & time combined with the customer's IP to make a unique id. I wouldn't've thought of that, but it sure makes sense to do it that way!

Drack

66.***.***.***
1,807 days ago
Brilliant idea to blend the IP and the time stamp together, rarely if ever will two orders have the same. So I'm guessing strtotime is built into the PHP/UNIX syntax?