GoLang DateTime::format

request it (572)
GoLang replacement for PHP's DateTime::format [edit | history]



Do you know a GoLang replacement for PHP's DateTime::format? Write it!

PHP DateTime::format

PHP original manual for DateTime::format [ show | php.net ]

DateTime::format

DateTimeImmutable::format

DateTimeInterface::format

date_format

(PHP 5 >= 5.2.1 < 5.5.0)

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

Description

Object oriented style

public string DateTime::format ( string $format )
public string DateTimeImmutable::format ( string $format )
public string DateTimeInterface::format ( string $format )

Procedural style

string date_format ( DateTimeInterface $object , string $format )

Returns date formatted according to given format.

Parameters

object

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

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

  • date() - Format a local time/date