Вопрос

i have the following line of code

$timestamp = '-'.(int)(microtime(true)*1000);

$timestamp gets appended onto the end of an order id to make it more unique, however, while i was testing on my local Wamp Server (on a Windows OS) i was getting values like this

-166776478
-166701036

as a test, i went and did order on a test server which is on unix, and i was getting values like this

1372722035
1372722471

for the last one in each what i did was open 2 firefox windows and did the orders almost at the same time (my local wamp server took a bit longer cause i didn't have any caching on

now, the weird thing is that i was expecting the values on my local Wamp server would be roughly the same as that as the test server

from my understanding microtime() eturns the current Unix timestamp since the Unix epoch with microseconds so timezone settings shouldn't have any affect

i'm wondering does microtime get different values if it's not running on unix and if not why am i getting 2 very different values

Это было полезно?

Решение

My guess what is happening is that on windows machine you are are overflowing the maximum value that can be represented as a integer.

Check the value of PHP_INT_MAX on both environments (echo PHP_INT_MAX;) The problem has probably less to do with windows vs linux and more to do with 32bit vs 64bit.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top