Collections functions
Encryption functions
General functions
Theme permission functions
Video functions
Resource functions

check_date_parts()

Description

Check datepart conforms to its formatting and error out each section accordingly

Parameters

ColumnTypeDefaultDescription
$parts
array array of the date parts

Return

string

Location

include/metadata_functions.php lines 246 to 287

Definition

 
function check_date_parts($parts)
    {
    global 
$lang;
    
    
// Initialise error list holder
    
$invalid_parts = array();
    
    
// Check day part
    
if (!checkdate('01',$parts[3],'2000'))
        {
        
array_push($invalid_parts'day');
        } 
    
// Check day month
    
if (!checkdate($parts[2],'01','2000')) 
        {
        
array_push($invalid_parts'month');
        } 
    
// Check year part
    
if (!checkdate('01','01',$parts[1])) 
        {
        
array_push($invalid_parts'year');
        }
    
// Check time part
    
if (isset($parts[4]) && isset($parts[5])) 
        {
        if (!
strtotime($parts[4] . ':' $parts[5]))
            {
            
array_push($invalid_parts'time');
            }
        }

    
// No errors found return false
    
if(empty($invalid_parts))
        {
        return 
false;
        } 
    
// Return errors found
    
else
        {
        return 
str_replace("%parts%"implode(", "$invalid_parts), $lang["date_format_error"]);
        }
    }

This article was last updated 21st September 2020 20:35 Europe/London time based on the source file dated 11th September 2020 17:00 Europe/London time.