Anonymous user / 216.73.216.183 Log In Register
?
Wallet: 3.00
Daily Credits:
1.20 / 1.20

PHP Functions Online


DateTime::format

(PHP 5 >= 5.2.0)

DateTime::format -- DateTimeImmutable::format -- DateTimeInterface::format -- date_formatReturns date formatted according to given format

public string $object->format(string $format)
public DateTime::__construct([string $time = "now"[, DateTimeZone $timezone = NULL]])
public DateTimeZone::__construct(string $timezone)

Checkout ? #

Item Description Item Price Your Price
Total

Preview #

${{ variable.param.name }} = {{ variable.param|getValue:variable.form:true }};
{{ call.result}} = ;

Tip: You can change some values by clicking on it in the preview above.

Description #

public string DateTime::format ( string $format )

Returns date formatted according to given format.

Parameters #

format

Format accepted by date().

Return Values #

Returns the formatted date string on success or FALSE on failure.

Examples #

Example #1 DateTime::format() example

Object oriented style

<?php
$date 
= new DateTime('2000-01-01');
echo 
$date->format('Y-m-d H:i:s');
?>

Procedural style

<?php
$date 
date_create('2000-01-01');
echo 
date_format($date'Y-m-d H:i:s');
?>

The above example will output:

2000-01-01 00:00:00

Notes #

This method does not use locales. All output is in English.

See Also #