PHP date_create_from_format() function

Mga Halimbawa

Ibibigay ang bagong DateTime object na naformat sa tinukoy na format:

<?php
$date=date_create_from_format("j-M-Y","25-Sep-2016");
?>

Mga Halimbawa ng Pagpapatupad

Pagsasakop at Paggamit

Ang date_create_from_format() function ay ibibigay ang bagong DateTime object na naformat sa tinukoy na format.

Mga Tagubilin

date_create_from_format(format,time,timezone);
Parameter Paglalarawan
format

Mga kinakailangan. Tukuyin ang format na gagamitin.format Ang string na parameter ay maaaring gamitin ang mga sumusunod na character:

  • ang bawat araw ng buwan, may nangungunang walang-laman na zero
  • ang bawat araw ng buwan, walang nangungunang walang-laman na zero
  • D - Day of the week (Mon - Sun)
  • I - Day of the week (Monday - Sunday)
  • S - English suffix for the day of the month (st, nd, rd, th)
  • F - Month name (January - December)
  • M - Month name (Jan - Dec)
  • m - Month (01 - 12)
  • n - Month (1 - 12)
  • Y - Year (e.g., 2013)
  • y - Year (e.g., 13)
  • a and A - am or pm
  • g - 12-hour format, without leading zero
  • h - 12-hour format, with leading zero
  • G - 24-hour format, without leading zero
  • H - 24-hour format, with leading zero
  • i - Minutes, with leading zero
  • s - Seconds, with leading zero
  • u - Microseconds (up to six digits)
  • e, O, P and T - Time zone identifiers
  • U - Seconds since Unix epoch
  • (Space)
  • # - One of the following delimiters: ;, :, /, ., -, (, )
  • ? - A random byte
  • * - Random bytes until the next delimiter/digit
  • ! - Reset all fields to Unix epoch
  • | - If all fields have not been parsed, reset all fields to Unix epoch
  • + - If present, trailing data in the string will cause a warning, not an error
time Required. Specifies the date/time string. NULL indicates the current date/time.
timezone Optional. Specifies time of the time zone. The default is the current time zone.

Technical Details

Return Value: Returns a DateTime object if successful, or FALSE if not.
PHP Version: 5.3+