Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeZaWeb committed Dec 24, 2021
1 parent 029b0e0 commit a331a83
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "freezaweb/validator",
"description": "POST/GET/CUSTOM array validator",
"license": "proprietary",
"version": "1.1.12",
"version": "1.1.13",
"type": "library",
"authors": [
{
Expand All @@ -16,4 +16,4 @@
"autoload": {
"classmap": ["src"]
}
}
}
36 changes: 36 additions & 0 deletions src/field_validate.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ public function float($params = null){
public function date($params = null){
$this->format_to_string = true;

if(empty($this->input)){
return $this->input;
}

if(isset($params[0])){
$format = $params[0];
}
Expand All @@ -291,6 +295,38 @@ public function date($params = null){



//$this->input = new \DateTime($this->input);
return $this;
}

public function time(){

if(empty($this->input)){
return $this->input;
}

$this->format_to_string = true;

$format = 'H:i';

$this->dateformat = $format;

$d = \DateTime::createFromFormat($format, $this->input);

if($d){
if($d && $d->format($format) == $this->input){
$this->input = $d;
}else{
if($this->required == true || $this->not_empty == true){
$this->add_error('format', 'false');
}
}
}else{
$this->add_error('format', 'false');
}



//$this->input = new \DateTime($this->input);
return $this;
}
Expand Down

0 comments on commit a331a83

Please sign in to comment.