Home Tutorial Php Phpdate date_format()

 
 

date_format()
Posted on: August 26, 2009 at 12:00 AM
date_format alias DateTime::format function returns date formatted according to given format. It returns formatted date on success otherwise False on failure.

date_format()

date_format alias DateTime::format function returns date formatted according to given format. It returns formatted date on success otherwise False on failure.

Description on date_format() PHP

public string DateTime::format ( string $format )
string date_format ( DateTime $object , string $format )

Parameters of PHP Date Format

object - Procedural style only: A DateTime object returned by date_create()

format - Format accepted by date().

Examples of PHP Date Formatting

<?php
date_default_timezone_set('India/Kolkata');

$datetime = date_create('2009-08-24 16:42:10');
echo date_format($datetime, 'jS, F Y') . "\n";
echo date_format($datetime, DATE_ATOM);
?>

Related Tags for date_format():


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.