php fmt formatdate,PHP IntlDateFormatter getDateType()用法及代码示例

IntlDateFormatter::getDateType()函数是PHP中的内置函数,用于获取用于IntlDateFormatter对象的日期类型。

用法:

面向对象的样式:int IntlDateFormatter::getDateType( void )

程序风格:int datefmt_get_datetype( IntlDateFormatter $fmt )

参数:此函数使用单个参数$fmt,该参数保存格式化程序的资源。

返回值:此函数返回格式化程序的当前日期类型值。

以下示例程序旨在说明PHP中的IntlDateFormatter::getDateType()函数:

程序1:

// Create a date formatter

$formatter = datefmt_create(

'en_US',

IntlDateFormatter::FULL,

IntlDateFormatter::FULL,

'Asia/Kolkata',

IntlDateFormatter::TRADITIONAL,

"MM/dd/yyyy"

);

// Get the date/type formatter type

echo 'Calendar of formatter: '

. datefmt_get_datetype($formatter) . "\n";

// Get the format of date/time value as a string

echo "Formatted calendar output: "

. datefmt_format( $formatter , 0) . "\n\n";

// Create a date formatter

$formatter = datefmt_create(

'en_US',

IntlDateFormatter::SHORT,

IntlDateFormatter::SHORT,

'Asia/Kolkata',

IntlDateFormatter::TRADITIONAL

);

// Get the date/type formatter type

echo 'Calendar of formatter: '

. datefmt_get_datetype($formatter) . "\n";

// Get the format of date/time value as a string

echo "Formatted calendar output: "

. datefmt_format( $formatter , 0);

?>

输出:

Calendar of formatter: 0

Formatted calendar output: 01/01/1970

Calendar of formatter: 3

Formatted calendar output: 1/1/70, 5:30 AM

程序2:

// Create a date formatter

$formatter = datefmt_create(

'en_US',

IntlDateFormatter::FULL,

IntlDateFormatter::FULL,

'Asia/Kolkata',

IntlDateFormatter::TRADITIONAL,

"MM/dd/yyyy"

);

// Get the date/type formatter type

echo 'Calendar of formatter: '

. $formatter->getDateType() . "\n";

// Get the format of date/time

// value as a string

echo "Formatted calendar output: "

. $formatter->format(0) . "\n\n";

// Create a date formatter

$formatter = datefmt_create(

'en_US',

IntlDateFormatter::SHORT,

IntlDateFormatter::SHORT,

'Asia/Kolkata',

IntlDateFormatter::TRADITIONAL

);

// Get the date/type formatter type

echo 'Calendar of formatter: '

. $formatter->getDateType() . "\n";

// Get the format of date/time

// value as a string

echo "Formatted calendar output: "

. $formatter->format(0);

?>

输出:

Calendar of formatter: 0

Formatted calendar output: 01/01/1970

Calendar of formatter: 3

Formatted calendar output: 1/1/70, 5:30 AM

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值