Add helper function format_http_date

This commit is contained in:
Pig Fang 2018-08-17 21:41:11 +08:00
parent 57bf10dbc5
commit 3ac4a98ecb

View File

@ -1,5 +1,6 @@
<?php
use Carbon\Carbon;
use App\Models\User;
use Illuminate\Support\Str;
use Illuminate\Support\Arr;
@ -435,3 +436,17 @@ if (! function_exists('get_db_config')) {
return config("database.connections.$type");
}
}
if (! function_exists('format_http_date')) {
/**
* Format a UNIX timestamp to string for HTTP headers.
*
* e.g. Wed, 21 Oct 2015 07:28:00 GMT
*
* @param int $timestamp
* @return string
*/
function format_http_date($timestamp) {
return Carbon::createFromTimestampUTC($timestamp)->format('D, d M Y H:i:s \G\M\T');
}
}