Change language

PHP Date_create_immutable_from_format () function

Syntax:
  • Object Oriented Style:
    DateTimeImmutable static DateTime::createFromFormat (string $format, string $time, DateTimeZone $timezone)
  • Procedural style:
    DateTimeImmutable date_create_from_format (string $format, string $time, DateTimeZone $timezone)
Parameters:This function takes three parameters as above and described below:
  • $format:This parameter contains the DateTime format in string.
  • $time:this parameter contains the time in string format.
  • $timezone:this parameter contains a DateTimeZone object.
Return Value:This function returns a new DateTimeImmutable object representing the date and time specified in a time string that has been formatted in the specified format.Per characters and their description: Format character Desciption Example returned values ​​ < / tr> j Day of the month without leading zeros 1 to 31 d Day of the month with leading zeros 01 to 31 m Numeric representation of the month 01 to 12 M Short textual representation of the month Jan to Dec Y Representation of a year 1989, 2017 < / tbody> The format string can be a combination of any format characters in any order, but we would have to provide the input date and time string in the same order.The programs below illustrate the date_create_immutable_from_format function() in PHP:Program 1:  
// Use the date_create_from_format() function
// create date format $date = date_create_from_format ( ’jMY’ , ’ 03-oct-2019’ );  
// Show date echo date_format ( $date , ’Ymd’ );  
?>
Exit:
2019-10 -03
Program 2:  
// Use the date_create_from_format() function
// create date format $date = date_create_from_format ( ’ dMY’ , ’03-oct-2019’ );  
// Show date echo date_format ( $date , ’Ymj’ );  
?>
Exit:
2019-10 -3
Program 3:  
// Use the DateTime::createFromFormat() function
// create a date object $date = DateTime::createFromFormat ( ’jMY’ , ’ 03-oct-2019’ );  
// Show date echo $date -> format ( ’ Ymd’ );  
?>
Exit:
2019-10 -03
Link: https://www.php. net / manual / en / datetimeimmutable.createfromformat.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