Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php validate date format

$date="2012-09-12";

if (preg_match("/^(20[0-9]{2})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/",$date)) {
    return true;
} else {
    return false;
}
Comment

php check valid time format

function isValidDate(string $date, string $format = 'Y-m-d'): bool
{
    $dateObj = DateTime::createFromFormat($format, $date);
    return $dateObj && $dateObj->format($format) == $date;
}
Comment

PREVIOUS NEXT
Code Example
Php :: twig trim space 
Php :: LaravelSocialiteTwoInvalidStateException 
Php :: php check if query returns results 
Php :: php connect ms sql server 
Php :: laravel required only one of multiple fields not both 
Php :: Artisan::call for all catch clear in laravel 
Php :: Laravel groupby date of created_at 
Php :: laravel eloquent get last 
Php :: print url in view yii2 
Php :: remove first element in array php 
Php :: laravel gigapay 
Php :: laravel print log 
Php :: add custom user meta and display it in user page 
Php :: php move_uploaded_file 
Php :: date to string in php 
Php :: remove array element in php 
Php :: num_rows in php 
Php :: remove action from theme wordpress 
Php :: php remove element from array 
Php :: how to update radio button value in database using php 
Php :: laravel blade check if yielded content exists 
Php :: palindrome in php 
Php :: laravel where first 
Php :: php clone object 
Php :: convert date php 
Php :: get html file data to variable in php 
Php :: smtp php test 
Php :: file to binary php 
Php :: php sql query where in array 
Php :: How do I check if a string contains a specific word? 
ADD CONTENT
Topic
Content
Source link
Name
5+1 =