دالة date_create_from_format() في PHP

مثال

يعود عمود DateTime جديد معتنى به لتنسيق معين:

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

مثال على التشغيل

التعريف والاستخدام

يعود الدالة date_create_from_format() بمثابة عمود DateTime جديد معتنى به لتنسيق معين.

النحو

date_create_from_format(format,time,timezone);
معلمات وصف
format

مطلوب. يحدد النمط الذي سيتم استخدامه.format يمكن استخدام الأحرف التالية في سلسلة المعلمات:

  • d - اليوم من الشهر، بصفر مقدم
  • j - اليوم من الشهر، بدون صفر مقدم
  • D - Day of the week (Mon-Sun)
  • I - Day of the week (Monday-Sunday)
  • S - Suffix of the day of the month in English (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
  • (空格)
  • # - 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 Time Zone. Default is the current time zone.

Technical Details

Return Value: Returns a DateTime object on success, FALSE on failure.
PHP Version: 5.3+