From a902a44927fcfba5deed9b910acc01ada927ac6f Mon Sep 17 00:00:00 2001 From: Pierre Date: Fri, 29 Dec 2017 09:46:10 +0100 Subject: [PATCH] Created mysql_date() function --- functions/strings.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/functions/strings.php b/functions/strings.php index cd67998..a9c4ab1 100644 --- a/functions/strings.php +++ b/functions/strings.php @@ -14,7 +14,7 @@ * to select from * @return string */ -function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') +function random_str(int $length, string $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') { $str = ''; $max = mb_strlen($keyspace, '8bit') - 1; @@ -22,4 +22,14 @@ function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzAB $str .= $keyspace[random_int(0, $max)]; } return $str; +} + +/** + * Get the current date formatted for the "datetime" object of + * a Mysql database + * + * @return string Formatted string + */ +function mysql_date() : string { + return date("Y-m-d h:i:s", time()); } \ No newline at end of file