0

I am using apache2 with php 7.1 in ubuntu 18.04

I have a laravel project (5.5) and when using:

{{ date('d-m-Y, H:i') }} 

in blade views the time is not correct (13:04 instead of 16:04).

I have set the timezone for the system:

sudo timedatectl set-timezone Europe/Bucharest

and in /etc/php/7.1/apache2/php.ini

date.timezone = Europe/Bucharest

Restart the pc, and the same problem.

Where do i have to set the timezone in ubuntu 18.04 for php?

calin24
  • 905
  • 3
  • 21
  • 43
  • 2
    You should not change server's timezone. That timezone must indicate server's location. You have to only define timezone on runtime using `date_default_timezone_set` http://php.net/manual/ru/function.date-default-timezone-set.php or in .env file for laravel app – num8er Jul 16 '18 at 13:32
  • Yea, you can use PHP's date_default_timezone_set() function: http://php.net/manual/en/function.date-default-timezone-set.php – TurtleTread Jul 16 '18 at 13:34
  • Take a look at this thread, here is listed many options on how to do this: https://stackoverflow.com/questions/32884388/change-timezone-in-lumen-or-laravel-5 – spectatorx Jul 16 '18 at 13:34

1 Answers1

6

if you want to set timezone in laravel then following are the step

1) open the app.php file path is : project\config\app.php

2) set 'timezone' value example

'timezone' => 'Europe/Bucharest'

ashish kumar
  • 172
  • 7