views:

136

answers:

1

Does PHP's date() function return the date and time on the server or on the client's computer?

+10  A: 

It returns the date/time on the server : PHP doesn't know anything about the client's browser.


Actually, PHP scripts can run even if there isn't a browser sending a request -- for instance, via a cron job.

Pascal MARTIN
Stack Overflow: ask a stupid question, get a well written and informative answer :)
Frank Farmer
@Franck : I take the "well written and informative" part as a compliment, thanks :-) (Even if I don't quite agree with the "stupid" part -- I've seen "worse")
Pascal MARTIN
Just to be more precise: The date() function doesn't return a date. It returns a formatted date string, using the timestamp passed in the second argument. If no second argument is passed, it defaults to formatting the current time on the server. Of course, the (Unix) timestamp on the server and the timestamp on the client will be the same, assuming they're both correct.
GZipp