★ wanayoo — archive 1999 http://www.php.net/manual/function.strftime.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Date/time
Quick Reference
Date/time
* checkdate
* date
* getdate
* gettimeofday
* gmdate
* gmmktime
* gmstrftime
* microtime
* mktime
* strftime
* time
Manual: strftime
View the source code for this pageSearch the site



Previous page
 mktime
time 
Next page


strftime

strftime -- format a local time/date according to locale settings

Description

string strftime(string format, int timestamp);

Returns a string formatted according to the given format string using the given timestamp or the current local time if no timestamp is given. Month and weekday names and other language dependent strings respect the current locale set with setlocale().

The following conversion specifiers are recognized in the format string:

  • %a - abbreviated weekday name according to the current locale

  • %A - full weekday name according to the current locale

  • %b - abbreviated month name according to the current locale

  • %B - full month name according to the current locale

  • %c - preferred date and time representation for the current locale

  • %d - day of the month as a decimal number (range 00 to 31)

  • %H - hour as a decimal number using a 24-hour clock (range 00 to 23)

  • %I - hour as a decimal number using a 12-hour clock (range 01 to 12)

  • %j - day of the year as a decimal number (range 001 to 366)

  • %m - month as a decimal number (range 1 to 12)

  • %M - minute as a decimal number

  • %p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale

  • %S - second as a decimal number

  • %U - week number of the current year as a decimal number, starting with the first Sunday as the first day of the first week

  • %W - week number of the current year as a decimal number, starting with the first Monday as the first day of the first week

  • %w - day of the week as a decimal, Sunday being 0

  • %x - preferred date representation for the current locale without the time

  • %X - preferred time representation for the current locale without the date

  • %y - year as a decimal number without a century (range 00 to 99)

  • %Y - year as a decimal number including the century

  • %Z - time zone or name or abbreviation

  • %% - a literal `%' character

Example 1. Strftime() example

  1 
  2 setlocale ("LC_TIME", "C");
  3 print (strftime ("%A in Finnish is "));
  4 setlocale ("LC_TIME", "fi_FI");
  5 print (strftime ("%A, in French "));
  6 setlocale ("LC_TIME", "fr_CA");
  7 print (strftime ("%A and in German "));
  8 setlocale ("LC_TIME", "de_DE");
  9 print (strftime ("%A.\n"));
 10       
This example works if you have the respective locales installed in your system.

See also setlocale() and mktime().


User Contributed Notes: strftime


zmajeed@cup.hp.com
22-Jul-1999 03:14
Locale names are OS dependent. HP-UX 11.0, for example, has three German locales, de_DE.roman8, de_DE.iso88591, and de_DE.iso885915@euro. The command locale -a will display all available locales on a system. So on HP-UX, to get German dates: setlocale("LC_TIME", "de_DE.roman8"); print(strftime("%A\n"));


ratatouil@free.fr
03-Mar-2000 08:37
when i run the example i've got this line : Saturday in Finnish is lauantai, in French samedi and in German Samstag. Or it's not the truth. Is it a bug ?


0348373e@teleline.es
08-May-2000 01:09
Para ponerlo en espaņol setlocale ("LC_TIME", "es_ES"); print(strftime("%A.\n"));


 About Notes


Previous page
 mktime
time 
Next page



Site Statistics


Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.