Datetime is saving -5:30 in database - laravel

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

Related

Laravel Timezone UTC but got a London

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.

Play Framework Date Parse Error

So i am having this issue with the play framework session dropping Play Session Dropping during payment tracking
I recently checked my logs and notices this stack trace coming up frequently
[debug] application - An invalidate date was received: Sat, 03 Oct 2015 23:08:37 UTC
java.lang.IllegalArgumentException: Invalid format: "Sat, 03 Oct 2015 23:08:37 UTC" is malformed at " UTC"
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:873) ~[joda-time.joda-time-2.3.jar:2.3]
at controllers.AssetInfo$.parseDate(Assets.scala:106) ~[com.typesafe.play.play_2.11-2.3.8.jar:1.0-SNAPSHOT]
at controllers.AssetsBuilder$$anonfun$controllers$AssetsBuilder$$maybeNotModified$3.apply(Assets.scala:326) [com.typesafe.play.play_2.11-2.3.8.jar:1.0-SNAPSHOT]
at controllers.AssetsBuilder$$anonfun$controllers$AssetsBuilder$$maybeNotModified$3.apply(Assets.scala:325) [com.typesafe.play.play_2.11-2.3.8.jar:1.0-SNAPSHOT]
at scala.Option.flatMap(Option.scala:170) [org.scala-lang.scala-library-2.11.1.jar:na]
I looked at this post on github (https://github.com/playframework/playframework/issues/3569) which is similar and says fixed but not sure if my version has the fix. I am using version 2.3.8.
Could this be causing my request to not have my session since it can not even parse the request?
Also do I need to update my version to fix this issue ?

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.

twitter4j api to post image to twitter,

I use twitter4j api to post image to twitter, initially my project worked without any exception but after further development it became unresponsive. Below is the error log form eclipse logcat.
com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate:
current time: Fri May 10 12:37:38 IST 2013, expiration time: Fri May 10 05:29:59 IST 2013
TwitterException{exceptionCode=[f69e96cd-138ff489 f69e96cd-138ff438 f69e96cd-138ff438 f69e96cd-138ff438 f69e96cd-138ff438], statusCode=-1, retryAfter=0, rateLimitStatus=null, version=2.1.6}
This happened since last night and I cant figure out whether this is due to twitter server error or not.
Somehow it seems the Certs are linked to your current date/time and any modification made there will cause this exception. Even I'm hunting for a perfect answer/resolution to this issue.

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