V
V
Vladislav Nagorny2017-03-12 06:15:27
MySQL
Vladislav Nagorny, 2017-03-12 06:15:27

How to get data in the desired time zone?

Good afternoon.
Faced a problem. I write down payment data with a date in UTC
. But when we check the data with the payment system, we get crooked graphs, because they calculate the data in Moscow time.
1. How can I make a selection to filter immediately by date in the desired zone?
2. What is the best way to store dates in the database?
There is payment number 1, we have it recorded in the database at 2017-03-10 23.00
and in the payment system it is at 2017-03-11
2.00 11')->sum('amount'); ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2017-03-12
@Stalker_RED

Keep UTC 0, when transferring to the client or somewhere else - convert.
In laravel, you can specify the time zone for your application in the config.

'mysql' => [
            'driver'    => 'mysql',
            'host'      => ...,
            'database'  => ...,
            'username'  => ...,
            'password'  => ...,
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
            'timezone'  => '+03:00'
        ],

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question