“Verifique a data php” Respostas de código

Verifique se a entrada é a data

function isRealDate($date) { 
    if (false === strtotime($date)) { 
        return false;
    } 
    list($year, $month, $day) = explode('-', $date); 
    return checkdate($month, $day, $year);
}
Wild Weevil

Verifique se a data já passou do PHP

$date = new DateTime($event['date']);
$now = new DateTime();
if($date < $now) {
    echo 'Date is in the past';
}
VasteMonde

Verifique a data php

function validateDate($date, $format = 'Y-m-d')
{
    $d = DateTime::createFromFormat($format, $date);
    // The Y ( 4 digits year ) returns TRUE for any integer with any number of digits so changing the comparison from == to === fixes the issue.
    return $d && $d->format($format) === $date;
}
Crazy Crossbill

Respostas semelhantes a “Verifique a data php”

Perguntas semelhantes a “Verifique a data php”

Mais respostas relacionadas para “Verifique a data php” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código