Latest web development tutorials

PHP date_format () function

PHP Date / Time PHP Date / Time Reference Manual

Examples

It returns a new DateTime object, and then format the date:

<?php
$date=date_create("2013-03-15");
echo date_format($date,"Y/m/d H:i:s");
?>

Running instance »

Definition and Usage

date_format () function returns a date formatted according to the specified format.

grammar

date_format( object,format);

参数 描述
object 必需。规定一个由 date_create() 返回的 DateTime 对象。
format 必需。规定日期格式。

technical details

return value: Returns a formatted date string. If it fails it returns FALSE.
PHP version: 5.2+


PHP Date / Time PHP Date / Time Reference Manual