وظيفة strptime() في PHP

مثال

تحليل الوقت/التاريخ المولد من strftime():

<?php
$format="%d/%m/%Y %H:%M:%S";
$strf=strftime($format);
echo("$strf");
print_r(strptime($strf,$format));
?>

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

يحلل strptime() الوقت/التاريخ المولد من strftime() التاريخ/الوقت المولد.

التعليقات:لم يتم تنفيذ هذه الوظيفة تحت نظام Windows.

القواعد

strptime(date,format);
الم参数 وصف
date مطلوب. النص الذي سيتم تحليله (مثلاً: النص الذي يعود منه strftime())
format

مطلوب. تحديد التنسيق الذي سيتم استخدامه في التاريخ:

  • %a - اختصار الاسم اليومي
  • %A - الاسم الكامل لليوم من الأسبوع
  • %b - اختصار الاسم الشهري
  • %B - الاسم الكامل للشهر
  • %c - طريقة التاريخ والوقت المفضلة
  • %C - الرقم الذي يمثل القرن (العام مقسوم على 100، من 00 إلى 99)
  • %d - اليوم من الشهر (01 إلى 31)
  • %D - تنسيق الوقت/التاريخ، بنفس طريقة %m/%d/%y
  • %e - اليوم من الشهر (1 إلى 31)
  • %g - مشابه ل %G لكن بدون القرن
  • %G - السنة الرابعة التي تتوافق مع عدد الأسبوعات الISO (انظر %V)
  • %h - بنفس طريقة %b
  • %H - الساعة، باستخدام النظام الزمني ال24 ساعياً (00 إلى 23)
  • %I - الساعة، باستخدام النظام الزمني ال12 ساعياً (01 إلى 12)
  • %j - اليوم من السنة (001 إلى 366)
  • %m - الشهر (01 إلى 12)
  • %M - الدقائق
  • %n - علامة النسخة
  • %p - am أو pm الذي يتوافق مع القيمة الزمنية المقدمة
  • %r - علامة الوقت صباحاً أو مساءً
  • %R - طريقة العلامة الزمنية بالساعات ال24
  • %S - الثواني
  • %t - مسافات التبويب
  • %T - الوقت الحالي، بنفس طريقة التعبير %H:%M:%S
  • 誀لرقم الذي يمثل اليوم من الأسبوع (من 1 إلى 7)،Monday[الإثنين] = 1. تحذير: في نظام Sun Solaris،Sunday[السبت] = 1
  • %U - السنة التي تحتوي على عدد الأسبوعات، من الأحد الأول كأول يوم من الأسبوع الأول
  • %V - Number of weeks contained in the year according to the ISO 8601 format (01 to 53), week 1 represents the first week of the year, at least four days, and Monday is the first day of the week
  • %W - Number of weeks contained in the year, starting from the first Monday, as the first week, and the first day is the first day of the week
  • %w - Decimal number representing a day of the week, Sunday[Sunday] = 0
  • %x - Preferred date representation without time
  • %X - Preferred time representation without date
  • %y - Year representation that does not include a digit representing the century (range from 00 to 99)
  • %Y - Year representation that includes a digit representing the century
  • %Z or %z - Time zone name or abbreviation
  • %% - Output a % character

Technical Details

Return Value:

If successful, this function returns an array with the parsed date. If failed, it returns FALSE.

The meanings of the array keys returned are as follows:

  • [tm_sec] - Number of seconds since the start of the current minute (0-61)
  • [tm_min] - Number of minutes since the start of the current hour (0-59)
  • [tm_hour] - Hour number since midnight (0-23)
  • [tm_mday] - Day of the month (1-31)
  • [tm_mon] - Number of months passed since January (0-11)
  • [tm_year] - Number of years passed since 1900
  • [tm_wday] - Number of days passed since Sunday (0-6)
  • [tm_yday] - Number of days passed since January 1 of this year (0-365)
  • [unparsed] - Date could not be parsed due to the specified format Identified Parts
PHP Version: 5.1+