Λειτουργία 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

Απαιτείται. Προτείνει πώς θα επιστρέψει το αποτέλεσμα:

  • Σύντομο όνομα ημέρας της εβδομάδας
  • Πλήρες όνομα ημέρας της εβδομάδας
  • Σύντομο όνομα μήνα
  • Πλήρες όνομα μήνα
  • Προτιμώμενη μορφή ημερομηνίας και χρόνου
  • Αριθμός αιώνα που εκφράζεται ως αριθμός (έτος / 100, από 00 έως 99)
  • Ημέρα του μήνα (01 έως 31)
  • Χρονική μορφή, όπως η μορφή %m/%d/%y
  • Ημέρα του μήνα (1 έως 31)
  • Όπως η μορφή %G, χωρίς τον αιώνα
  • Τετραψήφιο έτος που αντιστοιχεί στο ISO εβδομαδιαίο αριθμό (βλέπε %V)
  • Όπως η μορφή %b
  • Ώρα, σε 24ωρη μορφή (00 έως 23)
  • Ώρα, σε 12ωρη μορφή (01 έως 12)
  • Ημέρα του έτους (001 έως 366)
  • Μήνας (01 έως 12)
  • Λεπτό
  • Νέα γραμμή
  • am ή pm που αντιστοιχεί στο δοθέν χρονικό σημείο
  • Π.μ. και Μ.μ. σημαία χρόνου
  • 24ωρη σημαία χρόνου
  • Δευτερόλεπτο
  • Tabulator
  • Τρέχων χρόνος, ίδιος με τη μορφή %H:%M:%S
  • 蒧umeric representation of the day of the week (1 to 7), Monday[Monday] = 1. Warning: in Sun Solaris systems, Sunday[Sunday] = 1
  • %U - The number of weeks contained in the year, starting from the first Sunday, as the first week, as the first day of the week
  • %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, which must have at least 4 days and start with Monday as the first day of the week
  • %W - The number of weeks contained in the year, starting from the first Monday, as the first week, at least 4 days, and with Monday as the first day of the week
  • %w - Decimal number representing the day of the week, Sunday[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. Defaults to 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 comply with setlocale() current locale settings.

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