~`+=,.;:/?|'; $rnd_string = ''; for ($i = 0; $i < $length; $i++) { $rnd_string .= $chars[mt_rand(0, strlen($chars) - 1)]; } return $rnd_string; } public static function getTimeFormatted($timestamp = 0) { // set default time zone to UTC+8 date_default_timezone_set('Asia/Shanghai'); return ($timestamp == 0) ? date('Y-m-d H:i:s') : date('Y-m-d H:i:s', $timestamp); } }