Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time() function in PHP

Tags:

php

I just wanted to ask, since I'm coding a script, and I'm using time() as a salt for what I am doing.

Now what's happening is I'm salting the data sent from server 1, to server 2. Server 2 checks to see if the data = submitted_data + time() matches exactly. And I wanted to know, since my script will be used on different servers, will the time() function return the same value (if they're located in different parts of the world?)

A code example from the client is:

if($return == md5("true" . time()))

And a code example, where if the data that's submitted correctly, will return this:

echo md5('true' . time());

Both are on different servers in different parts of the world, but I wanted to know if using the time() will mess up the way my system's going to work..?

like image 883
Reverb Avatar asked May 05 '26 08:05

Reverb


1 Answers

Why don't you try following :

echo date("Y-m-d H:i") echo strtotime(date("Y-m-d H:i"));

Value of strtotime(date("Y-m-d H:i")); would not change until you pass the next minute OR you can remove "i" based on your requirement.

Hope that helps.

like image 105
sandeep Kumar Avatar answered May 07 '26 23:05

sandeep Kumar