PHP strftime() function

Halimbawa

Pagsasakop ng petsa at oras ayon sa sukat ng lugar:

<?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"));
?>

Mga Halimbawa ng Pagpapatupad

Pagsasakop at Paggamit

Ang function na strftime() ay pagbubuo ng format ng lokal na petsa at oras ayon sa sukat ng lugar.

Mga Payo:Tingnan ang gmstrftime() Mga function, pagbubuo ng format ng GMT/UTC petsa at oras ayon sa sukat ng lugar.

Mga Tagubilin

strftime(format,timestamp);
Parametro Paglalarawan
format

Mahalaga. Tumutukoy kung paano babalik ang resulta:

  • %a - Ang maikling pangalan ng araw ng linggo
  • %A - Ang buong pangalan ng araw ng linggo
  • %b - Ang maikling pangalan ng buwan
  • %B - Ang buong pangalan ng buwan
  • %c - Ang pinakapreferensyal na pagtatatakbo ng petsa at oras
  • %C - Ang numero ng siglo (taon ay hatiin ng 100, mula 00 hanggang 99)
  • %d - Ang araw sa buwan (01 hanggang 31)
  • %D - Format ng oras, katulad sa paggamit ng %m/%d/%y
  • %e - Ang araw sa buwan (1 hanggang 31)
  • %g - Katulad sa %G, ngunit walang siglo
  • %G - 4-digit na taon na tumutugma sa ISO linggo bilang (tumingnan %V)
  • %h - Katulad sa paggamit ng %b
  • %H - Oras, gamit ang 24-oras na sistema (00 hanggang 23)
  • %I - Oras, gamit ang 12-oras na sistema (01 hanggang 12)
  • %j - Ang araw sa taon (001 hanggang 366)
  • %m - Buwan (01 hanggang 12)
  • %M - Minute
  • %n - New line
  • %p - Am o pm na tumutugma sa binigay na oras
  • %r - Tagubilin ng oras sa a.m. at p.m. na sistema
  • %R - Tagubilin ng oras sa 24-oras na sistema
  • %S - Second
  • %t - Tab tab
  • %T - Ang kasalukuyang oras, katulad sa paggamit ng %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 in the year, starting from the first Sunday of the year as the first week, as the first day of the first week
  • %V - The number of weeks in the year according to the ISO 8601 format (01 to 53), week 1 represents the first week of the year, which must have at least four days and start with Monday as the first day of the week
  • %W - The number of weeks in the year, starting from the first Monday of the year as the first week, as the first day of the first week
  • %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 that does not include a number representing the century (range from 00 to 99)
  • %Y - Year representation that includes a number representing 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.

Names of months and days of the week and strings related to other languages adhere to setlocale() current locale settings.

PHP Version: 4+
Update Log: PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors.