kartik-v / yii2-datecontrol

Date control module allowing separation of date formats for View & Model for Yii Framework 2.0.
http://demos.krajee.com/datecontrol
Other
55 stars 29 forks source link

Problems with unix timestamp and convertion #132

Closed paulocoutinhox closed 4 years ago

paulocoutinhox commented 4 years ago

Hi,

Im using latest version of library and im search a lot for this but don't find anything that solve my problem.

  1. My domain class Banner has two fields: "start_at" and "end_at";
  2. Both fields are integer to store timestamp;

Problems:

  1. When i show the field value it shows as timestamp and not "d/m/Y H:i:s": image

  2. When i select any date and time it show only date on field:

image

  1. Validation of integer number fails because validation consider the date string and not the date as timestamp:

image

Can you help me use it correctly? I tried put the configurations on module, but no effect:

'modules' => [
        'datecontrol' => [
            'class' => '\kartik\datecontrol\Module',
            'saveTimezone' => 'UTC',
            'saveSettings' => [
                Module::FORMAT_DATETIME => 'php:U',
            ],
            'ajaxConversion' => true,
            'autoWidget' => true,
        ]
],

I tried put on field, but don't work:

<?php echo $form->field($model, 'start_at')->widget(DateTimePicker::class, [
    'options' => [
        'type'=>DateControl::FORMAT_DATETIME,
        'format' => 'datetime',
        'displayFormat' => 'Y-m-d',
        'saveFormat' => 'php:U',
        'saveTimezone' => 'UTC',
        'saveSettings' => [
            Module::FORMAT_DATETIME => 'php:U',
        ],
        'ajaxConversion' => true,
        'autoWidget' => false,
    ],
    'pluginOptions' => [
        'autoclose' => true,
        'todayHighlight' => true,
        'todayBtn' => true,
    ]
]); ?>

Thanks for any help.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/90089395-problems-with-unix-timestamp-and-convertion?utm_campaign=plugin&utm_content=tracker%2F1260533&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F1260533&utm_medium=issues&utm_source=github).
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.