Your question seems to demonstrate a bit of confusion about where date values come from. I will try to clarify for you:
PHP code runs on your web server, and so when you call date()
, the DateTime returns the current date on the server. (You added a comment after I wrote this that clarified that this seems to be the source of your confusion: if you're running your application in XAMPP then your local machine is your server, and so changing your clock time would change the value returned by date()
)
If you want to know the date on the client (the user interacting with your system instead), and make that date available to your PHP code, you would need to have the client submit it, for example using AJAX.
If you want to know the date as defined by some official authority, independent of the system settings of your server or your user, you could send a request to NIST at http://nist.time.gov/actualtime.cgi. Rather than doing that in your PHP code, though, I would suggest simply setting your server time to be accurate and using date()
.