Ronald Ronald - 19 days ago 7
PHP Question

Laravel doesn't fetch date/time from server

I'm using laravel with xampp as it's server. But it doesn't seem to get the proper time. I tested this by having this code:

echo $today = date("Y-m-d H:i:s");
on a page in "htdocs" (not laravel just plain php) and on a function inside a laravel controller. The "today.php" in htdocs work while the one in laravel doesn't.

Any idea where I can configure the date/time in my laravel application?

Thanks!

Answer

To solve the problem, I set Default time zone in controller, but this is tedious though since I have multiple controllers.

date_default_timezone_set('Asia/Kolkata');
$today = new DateTime();