8.4.2 time zones, locales, datetime mess

Permalink
I have a multilingual site with 2 locales: ru_RU (default) and an en_GB.

I have 2 datetime widgets:
echo $app->make('helper/form/date_time')->datetime('pickup_dt', $dh->formatDateTime('tomorrow 09:00:00'), false, true, null, 1800, array());
echo $app->make('helper/form/date_time')->datetime('dropoff_dt', $dh->formatDateTime('tomorrow 09:00:00'), false, true, null, 1800, array());

The site (server, system) is on a Moscow time zone.

When Russian language is selected, the widgets show the dates in the Russian format, i.e. 05.11.2018 and say 30.11.2018.

Controller compares the two:
if (strtotime($dropoff) < strtotime($pickup)) {
    // Error
}

It works fine in Russian. The $pickup and $dropoff are set by ajax as
'pickup': $('#pickup_dt_dt_pub').val(),
'dropoff': $('#dropoff_dt_dt_pub').val(


But when I change the language to English, the widgets show the dates as 11/05/2018. When I click on the date, it shown May as the month. If I pick 05 and 30 Nov: the first one is shown as 05/11/2018 and the second as 30/05/2018, the controller returns the error because the 2nd time is less than the 1st. Looks like the widget swaps days and months in English.

How should I set the tomorrow's datetime to make sure it works properly in both languages?

How do I force the widget to show dates as picked without swapping days and months?

linuxoid
 
linuxoid replied on at Permalink Reply
linuxoid
I got it!

The widget should be set as
$dt = date('Y-m-d H:i:s', strtotime('tomorrow 09:00:00'));
echo $app->make('helper/form/date_time')->datetime('pickup_dt', $dt, false, true, null, 1800, array());


and the value in jQuery should be checked as
'pickup': $('#pickup_dt_dt').val()

Now the returned values are always in the same format Y-m-d regardless of the language.