I am trying to echo date, simple code, but result is not correct for my country.
Result is 04.10.2014
and it should be 03.10.2014
Here is my code
PHP
<?php
date_default_timezone_set("Europe/Sarajevo");
$my_date = date("d.m.Y");
echo $my_date;
?>
Make sure your server's timezone is set correctly because PHP always uses the default sever time as a reference.
Check if correct by:
echo date_default_timezone_get . ' ' . date('Y-m-d H:i:s);
You'll know if your server's time zone is messed up if the above code returns something unexpected.
If it is messed up, you'll just have to adjust your timezone offset manually.
If you need to change your timezone, just change this via system settings on Windows/Mac. If you're on Linux try these:
Ubuntu: dpkg-reconfigure tzdata
Redhat: redhat-config-date
CentOS/Fedora: system-config-date
FreeBSD/Slackware: tzselect
Hope this helps!
Navigate to C:\\xampp\\php\\php.ini or your path, open it.
Find:
date.timezone = "<something>"
Change it to date.timezone = "Europe/Sarajevo"
Restart your XAMPP
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.