Both of those code are generate the same timestamp, so what their diff??
Does it affect the speed of processing??
echo date_timestamp_get(date_create()); // e.g. 1478854173
echo time(); // e.g. 1478854173
And does it depend on the local time of user? Or depends on the local time of server?
As you can see the first approach is using two function calls, while the second is done with just one call. So theoretically using just time()
should be faster ... in a matter of microseconds or less.
The only benefit of the first approach is that you can pass whatever date you want to date_create()
and get its timestamp like this:
date_timestamp_get(date_create('2016-12-12 12:00:00'));
while time()
returns you the current timestamp.