Convenience functions are functions that perform a specific task, independant of the program, code or whatever that called it.
Here's an example in PHP:
function currentDateTime(){
list($micro, $Unixtime) = explode(" ",microtime());
$sec= $micro + date("s", $Unixtime);
$sec = mb_ereg_replace(sprintf('%d', $sec), "", ($micro + date("s", $Unixtime)));
return date("Y-m-d H:i:s", $Unixtime).$sec;
}
This function does one thing only: return a string that represents the DateTime of the moment if was called, ready to be inserted into any database, no matter which PHP file called it.
I wonder, are there any reasons not to keep a bunch of "convenience functions" in a file(or multiple files, based on subject), for use in every project you'll ever work on?
Mind you all, I'm a beginning programmer. I'm not really up to speed to what most people do, but I'm thinking it's handy to keep such a file for future reference and ease of development.
But what should I be mindfull of? Are there any standard? Or do you simply re-invent the wheel everytime you get a new project?