Share on Google+Share on Google+

date_format()

Advertisement
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);
?>

Advertisements

Posted on: August 26, 2009 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.