وظيفة strftime() في PHP
مثال
تنسيق التاريخ والوقت المحلي بناءً على إعدادات المنطقة:
<?php
echo(strftime("%B %d %Y, %X %Z",mktime(20,0,0,12,31,98))."<br>");
setlocale(LC_ALL,"hu_HU.UTF8");
echo(strftime("%Y. %B %d. %A. %X %Z"));
؟؟
مثال على التشغيل
التعريف والاستخدام
تقوم الوظيفة strftime() بتشكيل التاريخ والوقت المحلي بناءً على إعدادات المنطقة.
نصيحة:انظر gmstrftime() الوظيفة، تتناسب مع إعدادات المنطقة لتشكيل الوقت/التاريخ GMT/UTC.
النحو
strftime(format,timestamp);
المتغيرات |
وصف |
format |
مطلوب. يحدد كيفية رجوع النتيجة:
- %a - اختصار الاسم اليومي
- %A - الاسم الكامل لليوم من الأسبوع
- %b - اختصار الاسم الشهري
- %B - الاسم الكامل للشهر
- %c - شكل التاريخ والوقت المفضل
- %C - الرقم الذي يظهر القرن (السنة divided by 100، من 00 إلى 99)
- %d - اليوم في الشهر (01 إلى 31)
- %D - تنسيق الوقت، مشابه لـ %m/%d/%y
- %e - اليوم في الشهر (1 إلى 31)
- %g - مشابه لـ %G لكن بدون القرن
- %G - السنة المعادلة لعدد الأسبوعات ISO باستخدام 4 أرقام (انظر %V)
- %h - مشابهة لـ %b
- %H - الساعة باستخدام نظام الـ 24 ساعة (00 إلى 23)
- %I - الساعة باستخدام نظام الـ 12 ساعة (01 إلى 12)
- %j - اليوم في السنة (001 إلى 366)
- %m - الشهر (01 إلى 12)
- %M - الدقائق
- %n - علامة النسخة
- %p - am أو pm المترادف مع القيمة الزمنية المقدمة
- %r - علامة الوقت a.m. و p.m.
- %R - طريقة العلامة الزمنية باستخدام الـ 24 ساعة
- %S - الثواني
- %t - مسافات النسخة
- %T - الوقت الحالي، مشابهة لـ %H:%M:%S
- 蒧umeric representation of the day of the week (1 to 7), Monday[星期一] = 1. Warning: In Sun Solaris systems, Sunday[星期日] = 1
- %U - The number of weeks contained in the year, starting from the first Sunday, as the first week, the first day of the first week is Sunday
- %V - The 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 - The number of weeks contained in the year, starting from the first Monday, as the first week, the first day of the first week is Monday
- %w - Decimal representation of the day of the week, Sunday[星期日] = 0
- %x - Preferred date representation without time
- %X - Preferred time representation without date
- %y - Year representation without a number indicating the century (range from 00 to 99)
- %Y - Year representation containing a number indicating the century
- %Z or %z - Timezone name or abbreviation
- %% - Output a % character
|
timestamp |
Optional. Specifies the Unix timestamp representing the date/time to be formatted. The default is the current time (time()) |
Technical Details
Return Value: |
returns based on format using the given timestamp formatted strings.
The names of months and weekdays and strings related to other languages comply with setlocale() current locale settings.
|
PHP Version: |
4+ |
Update Log: |
PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors. |