Taking current date

I am trying to take current date on my XAMP server and it is showing me

$startDate = date(“Y-m-d”);
echo $startDate;
//2023-10-27

even though today is 26th. How would I take a date correctly so when this piece of code runs on different web server current date will be correct?

it’s the 27th in Unix Time. (EDIT: No it’s not Marc. XAMPP is created by people in Berlin.)
date() is timezone-independant by default.

Check the value of the date.timezone setting in your config; or set it with date_default_timezone_set.

[Date]
; Defines the default timezone used by the date functions
; https://php.net/date.timezone
;date.timezone =

If i change this how this is going to affect when code runs on different server?

The date function will return whatever the current date is in the server’s defined timezone. So when you change server, the date will return that server’s date in whatever timezone its set to.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.