Change language

PHP Date_parse_from_format () function

Syntax:
array date_parse_from_format ($format, $date) 
Parameters:This function takes two parameters, as above and described below:
  • $format:these are required parameters and are used to specify the date format. The following parameter line is used in the format.
  • Day :
    • d and j:represents the day of the month, 2 digits with or without leading zeros them.
    • D and l:textual representation of the day.
    • S:English ordinal suffix for the day of the month, 2 characters. This is ignored during processing.
    • z:day of the year (starting at 0)
  • Month:
    • F and M:textual representation of the month, such as January or September
    • m and n:numeric representation of the month with or without leading zeros
  • Year :
    • Y:full numeric representation of the year, 4 digits
    • y:two-digit year (assuming 1970-2069 inclusive)
  • Time:
    • A and A:ante meridium and post meridium
    • g and h:12- hour format with or without zeros
    • G and H:24-hour hour format with or without leading zeros
    • i: minutes with leading zeros
    • s:seconds, with leading zeros
    • u:microseconds (up to six digits)
  • Time zone:
    • e, O, P and T:time zone identifier, or UTC difference in hours, or the difference from UTC with a colon between hours and minutes, or a time zone abbreviation
  • Full date / time:
    • U:seconds since Unix start (Jan 1, 1970 00:00:00 GMT)
  • Spaces and separators :
    • (space):one space or one tab
    • #:One of the following separator characters :; ,:, / ,. ,,, -, (or)
    • ;,:, / ,. ,,, -, (or):the specified character.
    • ?:Random byte
    • *:Random bytes until next delimiter or number
    • !:Resets all fields (year, month, day, hour, minute, second, fraction and time zone information) to Unix epoch
    • |:Resets all fields (year, month, day, hour, minute, second, fraction, and timezone information) to Unix epoch if not already parsed
    • +:If this format specifier is present, the final data in the line will not throw an error, but instead generate a warning
  • $date:this is a required parameter and is used to represent the date.
Return value:this function returns an array containing a detailed description of the date.The following programs illustrate the date_parse_from_format() function in PHP.  
// Declare and initialize the date variable. $date = "0.9.2018 5: 00 + 01: 00" ;  
// This function is used to return date information. print_r (date_parse_from_format ( "jnY H: iP" , $date )); ?>
Exit:
Array ([ year] = > 2018 [month] = > 9 [day] = > 0 [hour] = > 5 [minute] = > 0 [second] = > 0 [fraction] = > [warning_count] = > 1 [warnings] = > Array ([19] = > The parsed date was invalid) [error_count] = > 0 [errors] = > Array() [is_localtime] = > 1 [zone_type] = > 1 [zone] = > -60 [is_dst] = >) 
Program 2:  
// Declare and initialize a variable date. $date = "2015.0 .9 " ;  
// This function is used to return date information. print_r (date_parse_from_format ( "Yzn" , $date )); ?>
Exit:
Array ([ year] = > 2015 [month] = > 9 [day] = > 1 [hour] = > [minute] = > [second] = > [fraction] = > [warning_count] = > 0 [warnings] = > Array() [error_count] = > 0 [errors] = > Array() [is_localtime] = >) 
Related article:
  • PHP | Date_sun_info() function
  • PHP | Date_sunset() function
  • PHP | Date_parse() function
Link: http://php.net/manual/en/function.date-parse-from-format.php

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically