Search code examples
phplaraveldatetimelaravel-5php-carbon

not accurate local time laravel 5


I use carbon to get the current local date and time by

$mytime = Carbon::now();
dd(var_dump($mytime->toDateTimeString()));

and I get this result

2015-11-21 13:20:05

and in my local time I have 9:20 PM (21:20 when 24hours format). Any ideas why time does not match?


Solution

  • Carbon::now() should give you the server's time zone, not the user's.

    Check your phpinfo() and see if your time zone is set accurately.