I am using laravel 5.2
I want to save the India time in our created field can anyone help me how to do that. What type of setting I have to do that when user registers? I want the India time to be stored on created_at field. Like in whatsapp chat you saw that when we chat in India it will display the India timings when we chat.
Here is my Code:
$current = Carbon::now();
$current = new Carbon();
$today = Carbon::today();
but it returns me UK time date.
you can set the timezone by date_default_timezone_set('Asia/Kolkata'); check PHP: Asia Manual for other timezones in Asia.
Go to your_project/config/app.php
, there is a line:
'timezone' => ''
set it to:
'timezone' => 'Asia/Kolkata'
It will set the default timezone to Asia/Kolkata
. After setting this you will get Indian time.
Here is the list of Supported Timezones
$var = Carbon::now('Asia/Kolkata');
return $time = $var->toTimeString();
I had the same issue. The above code is working fine for me. Hope it helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With