Change language

PHP IntlDateFormatter format () Function

Syntax:
  • Object Oriented Style:
    string IntlDateFormatter::format (mixed  $value)
  • Procedural style:
    string datefmt_format (IntlDateFormatter $fmt, mixed $value)
Parameters:This function uses two parameters as above and described below:
  • fmt:this parameter contains a date object resource.
  • value:this parameter contains a value in the format. It can be a DateTimeInterface object, an IntlCalendar object, or a numeric type representing the number of seconds. If a DateTime or IntlCalendar object is passed, it is not considered.
Return Value:This function returns a formatted string on success, or False on an error. The following program illustrates the IntlDateFormatter::format() function in PHP:Program :  
// Create a date formatter $fmt = datefmt_create ( ’ en_US’ , IntlDateFormatter::LONG, IntlDateFormatter::LONG, ’Asia / Kolkata’ , IntlDateFormatter::GREGORIAN );  
// Display the date in the specified format echo ’Formatted output using object oriented style:’ . $fmt -> format (0). "" ; echo ’ Formatted output using procedural style: ’ . datefmt_format ( $fmt , 0). "" ;  
// Create a date formatter $fmt = datefmt_create ( ’en_US’ , IntlDateFormatter::SHORT, IntlDateFormatter::SHORT, ’Asia / Kolkata’ , IntlDateFormatter::GREGORIAN );  
// Display the date in the specified format echo ’Formatted output using object oriented style:’ . $fmt -> format (0). "" ; echo ’ Formatted output using procedural style: ’ . datefmt_format ( $fmt , 0);  
?>
Exit:
Formatted output using object oriented style: January 1, 1970 at 5:30:00 AM GMT + 5: 30 Formatted output using procedural style: January 1, 1970 at 5:30:00 AM GMT + 5: 30 Formatted output using object oriented style: 1 / 1/70, 5:30 AM Formatted output using procedural style: 1/1/70, 5:30 AM
Link: https://www.php.net/manual/en/intldateformatter.format.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method