Returns a date/time string with the specified timestamp format
$time = Date::formatted_time('5 minutes ago');
string Core_Date::formatted_time( [ string $datetime_str = string(3) "now" , string $timestamp_format = null , $timezone = null ] )
参数列表
参数 类型 描述 默认值 $datetime_str
string
Datetime_str datetime string string(3) "now" $timestamp_format
string
Timestamp_format timestamp format null $timezone
unknown
null
string
587588589590591592593594595public
static
function
formatted_time(
$datetime_str
=
'now'
,
$timestamp_format
= NULL,
$timezone
= NULL)
{
$timestamp_format
= (
$timestamp_format
== NULL) ?
Date
::
$timestamp_format
:
$timestamp_format
;
$timezone
= (
$timezone
=== NULL) ?
Date
::
$timezone
:
$timezone
;
$time
=
new
DateTime(
$datetime_str
,
new
DateTimeZone(
$timezone
?
$timezone
: date_default_timezone_get()));
return
$time
->format(
$timestamp_format
);
}