D
D
Dmitry2016-11-19 22:47:36
Yii
Dmitry, 2016-11-19 22:47:36

How to convert time to seconds in DateControl?

Goodnight.
On the site, in the form I use DateControl .
I figured out a little with the plugin, but two questions arose.
The first question:
I need to save the date and time in unixtime format in separate fields of the table.
In the plugin settings I specified the following:

<?php
        'datecontrol' =>  [
            'class' => '\kartik\datecontrol\Module',
// остальные настройки удалил, чтобы не растягивать)))
            'saveSettings' => [
                Module::FORMAT_DATE => 'php:U',
                Module::FORMAT_TIME => 'php:U'
            ],
        ]
?>

The fields in the base are of type integer(11). With these settings, the date is stored normally, but the time is stored as "-2147483648"
How can I make the time stored in seconds? Or is it better to make a field in the string table and store the time in the format "00:00" (there will be no search for this gender, just for information)?
And the second question is how to make the date in the second DateControl impossible to select less than in the first one?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2016-11-20
@slo_nik

Keeping the time and date separate is weird, since data in unix format already contains the time. Why another field?
And what confuses you is: 12/13/1901 @ 23:17:11 MMT (GTM +02:31)
In general, it is difficult to store time without a date in this format. Since this is the number of seconds since midnight (00:00:00 UTC) on January 1, 1970. Accordingly, whatever value you specify, it contains the value of both the date and time.
The DateControl should not be able to do this, unlike the widget you use to do this. And in the widget settings, there is probably such an opportunity.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question