在PHP和MySQL中,unix时间戳是否总是相同的?

PHP has time(), MySQL has UNIX_TIMESTAMP().

Will these always be equal, on a given machine?

I expect the answer is normally yes, but are there any edge cases?

They will always be equal on the same machine at the same time.

Do note that it's fairly common for MySQL to be hosted on a second machine, which'll open up the possibility for minor differences (in normal operation, from things like networking latency as the query's returned to the machine making the query) and possibly larger differences (if one/both of the servers have an incorrect time locally).

Yes, they will always represent the same time, plus or minus any differences in the time it takes to execute one another.

This is because both time() and UNIX_TIMESTAMP() return the number of seconds since the Unix Epoch, and the Unix Epoch is UTC, which is by-design agnostic to time zones and daylight savings time.

It should also be noted that if you're working with a specific date that you're converting into a unix timestamp, then time zones WILL make a difference.