This my library filename: MY_is_date_helper.php
function is_date($date){
$d = DateTime::createFromFormat('Y-m-d', $date);
return $d && $d->format('Y-m-d') == $date;
}
My question is how can I call it to my MVC using just like this:
is_date('2000-01-01');
like what the base_url()
did without creating any file at the system folder.
Thanks in advance.
Save file in application/helpers dir
Then you need to load your helper in controller like
$this->load->helper('MY_is_date_helper');
Or add it to autoload in config
$autoload['helper'] = array('MY_is_date_helper');
You can do this in your current php file where you want to use finction -
<?php
include 'MY_is_date_helper.php';
is_date('2000-01-01'); // call function
?>