Reputation: 21901
I'am using Carbon
for manipulating dates in a laravel project.
Carbon::now('+5:30');
Above code is working fine in local environment but not in development environment.
This is what i get on dd(Carbon::now('+5:30'));
1 - IN LOCAL ENVIRONMENT php version - 5.6.3
2 - IN DEVELOPMENT ENVIRONMENT php version - 5.5.9-1ubuntu4.14
But both environment behaves same if i use timezone name instead of time-offset like,
Carbon::now('Asia/Tokyo');
Is this something about the php-version or something else?
Upvotes: 2
Views: 3404
Reputation: 1520
I have an answer for you after searching for related issues.
It seems that PHP version 5.5.9 had a bug:
https://stackoverflow.com/a/14069062/5912664
So you can't use that method with Carbon, but the following should work:
Carbon::now()->addHours(5)->addMinutes(30);
You can place your servers timezone in there for added accuracy:
Carbon::now(date_default_timezone_get())->addHours(5)->addMinutes(30);
Upvotes: 2
Reputation:
you can change in
'timezone' => 'UTC'
This time zone must match to your country zone.So replace this UTC with your current zone.
Upvotes: 1