Получить самую старую дату из массива дд / мм / гг

Это решение сработало для меня

;(function($){
    // your code
})(jQuery);

Перенесите свой код внутри замыкания и используйте $ вместо jQuery

Я нашел указанное решение в https://magento.stackexchange.com/questions/33348/uncaught-typeerror-undefined-is-not-a-function-when-using-a-jquery-plugin-in-ma

... после поиска слишком много

2
задан cgee 3 March 2019 в 11:58
поделиться

1 ответ

Это должно сработать:

$oldestPerson = null;
$oldestBirthday = new DateTime();  // preparing to save the oldest found birthday to compare against

for($i=0; $i<count($persons);$i++){
    // create a DateTime Object out of the birthday-string
    $birthday = DateTime::createFromFormat("d/m/y", $persons[$i]['Birthday']);

    if($birthday < $oldestBirthday){  // compare this to the oldest (=smallest) saved one
        $oldestPerson = $persons[$i]; // update
        $oldestBirthday = $birthday;  // update
    }
}

print_r($oldestPerson);
0
ответ дан Jeff 3 March 2019 в 11:58
поделиться
Другие вопросы по тегам:

Похожие вопросы: