Does PHP's date()
function return the date and time on the server or on the client's computer?
views:
136answers:
1
+1
Q:
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
2009-12-24 15:00:06
Stack Overflow: ask a stupid question, get a well written and informative answer :)
Frank Farmer
2009-12-24 15:04:59
@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
2009-12-24 15:09:31
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
2009-12-24 15:38:41