Laravel Timezone UTC but got a London - laravel

I have a question
In Laravel config/app timezone = UTC
But my localhost is in Japan, `created_at time is London

I not sure that I have understood your question but... you are saying your locale config is UTC therefore you application runs with the correct configured timezone.
If you want to set a different timezone you should change it in config/app.php.
Check all available timezones in php: http://php.net/manual/es/timezones.php
Kind regards

You can set your timezone in laravel config/app like this
'timezone' => 'Asia/Tokyo'
This should solve your problem. With reference to http://php.net/manual/en/timezones.php
Regards.

Related

Datetime is saving -5:30 in database

I'm passing datetime to api from my application, but is is saving 5:30 less in database. I'm using laravel for api & react in frontend application.
My date format is, Thu Oct 12 2017 11:00:00 GMT+0530 (IST).
When I checked in database, it saved as 2017-10-12 05:30:00.
How can I save exact datetime ?
Thank You
By default laravel set your application timezone to UTC, you have to configure the timezone in config/app.php as 'timezone' => 'Asia/Kolkata'
you can refer different timezones here

gmail working great on laravel site, trouble swapping with domain email creds from register.com

I'm using my personal gmail to send messages from my laravel 5.1 site (working great), and I'd like to update this to send from a domain mailbox I have through register.com (aka web.com).
I'm not finding a great resource on web.com, only this: https://knowledge.web.com/Support/70044/70044/en-US/Article/View/24/How-Do-I-Get-Started-with-POP3-and-IMAP/0
But it looks like the port/driver stays the same, so I've swapped the bottom three values in my .env file:
MAIL_DRIVER=smtp
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_HOST=smtp.ourbigfamilytree.com
MAIL_USERNAME=diane#ourbigfamilytree.com
MAIL_PASSWORD=(my password)
I did these to make sure the new values get used:
php artisan cache:clear
php artisan config:cache
In mail.php, I make use of those env variables (I don't override them), and I updated the 'from' address to match to make sure it's consistent:
'from' => ['address' => 'diane#ourbigfamilytree.com', 'name' => 'Diane Kaplan'],
When I trigger an email I get:
Connection could not be established with host smtp.ourbigfamilytree.com [Connection timed out #110]
Any ideas of what could be wrong? I've heard that godaddy 'blocks' the smtp ports, so I hope it's not something like that- anyone know a good way to determine that? I wasn't able to find the answer on their knowledgebase, but I also haven't messed with email much so I'm not sure I'm using the right search terms.
thanks in advance for any help/ideas-
Diane
It's not the exact answer, but in the long run you will have much less trouble using actual mail service providers rather than hooking into gmail like that.
Mailgun is excellent, easy to set up with a custom domain, and if you have such little traffic that using gmail was an initial solution, you will most likely fall within the free tier of Mailgun.
https://mailgun.com
Bonus points: Laravel has Mailgun front of mind, so very easy to set up.

Created_at save with the wrong timezone

I have a laravel app and i'm trying to save the users checkins and checkouts to my database
i have a model Checkins and i record it like created_at and updated_at
on my localhost it save with the right time for my timezome ( Egypt ), i tried to changed app.php file to the following
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
| This is a bad thing really i think there is a problem within the server, the datetime
*/
'timezone' => 'EET',
it's working just fine on my localhost and save with the current right time, for the production it's save with UTC timezone
Also when i write in the production terminal the command date date, i get the following
Tue Mar 31 12:46:38 EET 2015
and i checked mysql for the timezone and i found it's getting the time from the system time
SELECT ##global.time_zone, ##session.time_zone;
SYSTEM
What's wrong here ?
UPDATE:
I created a php page with date('H:i:s'); and it's print the right time
To set the timezone for your Laravel app, change the 'timezone' in your config/app.php
|--------------------------------------------------------------------------
| Application Timezone
|--------------------------------------------------------------------------
|
| Here you may specify the default timezone for your application, which
| will be used by the PHP date and date-time functions. We have gone
| ahead and set this to a sensible default for you out of the box.
|
| This is a bad thing really i think there is a problem within the server, the datetime
*/
'timezone' => 'America/Los_Angeles',
You can find the timezone you need here.
You have to change yout time zone in config/app.php
Also as is said here you must run following commands for your time zone changes to be saved:
php artisan cache:clear
php artisan view:clear
php artisan config:cache
Maybe you use insert or insertGetId to insert the data?
If you use Eloquent(like ->save()) to insert data, the time will be right.
As per php documentation It is strongly recommended that you use the correct time zone for your location, such as Asia/Shanghai or Australia/Perth Not use EET or CET.
Your can find timezone for your location here
Looks like you forgot to run php artisan config:cache.

Laravel log not showing system time

I seem to have a strange problem that I cant find and answer to.
When I run into any error in Laravel and I look at the log file, the time stanp shown in the log file is different from my system time.
Can someone help me fix this?
How can I update Laravel to show correct time?
Look at your app/config/app.php
There should be a field called timezone in which you could specify app-wide timezone, including your logs to match your system timezone.

Time zone problem in Codeigniter

I have set the default time zone like date_default_timezone_set('America/New_York');
But the time is exactly 4 hrs advance.
(ie) if Current time is 6:00:00 then its saving as 10:00:00
Don't know whats wrong. Its working perfectly in localhost but not in godaddy server.
Have you tried asking godaddy? I'm fairly sure date_default_timezone_set is a native PHP function and not related explicitly to CodeIgniter:
http://php.net/manual/en/function.date-default-timezone-set.php

Resources