PHP provides several features designed to save the date in your preferred format. Basic to date. Its first argument is a text string that serves as a description of the format. Each letter inserted into this string will be converted to a date element.
For example, the letter Y ‚will be converted to a year in the form of four digits. For a complete list of items format can be found in the description of the function date ().
// Assuming today is May 7, 2010, 8:31:11 p.m.
$today = date ( „F j, Y, g: i a”); // May 7, 2010, 20:31 pm
$today = date ( „m.d.y”); // 07.05.10
$today = date ( „j, n, Y ‚); // 7, 5, 2010
$today = date ( „Ymd”); // 20100507
$today = date (h-s-i-j-m-s, it is in the Day ‚); // 20-31-11, 7-05-10, 3128 3111 1 37 Monpm05
$today = date ( ‚\ i \ t \ and \ s \ t \ h \ e jS \ d \ a \ s.’); // It is the 7th day.
$today = date ( „D j G M: i: s T Y”); // Sat Feb 7 2010 8:31:11 p.m. PST
$today = date ( ‚H: m: s \ m \ t \ o \ \ m \ i \ s \ s \ and \ a \ c’); // 8:05:11 p.m. m this month
$today = date ( „H: i: s”); // 8:05:11 p.m.
As you can see, most of the characters has its meaning, so it is not possible to insert plain text, in addition to replace them escape sequences.
The default display is properly formatted date and the current time. This can be changed by specifying the optional second parameter – the time in the timestamp format. Then the format will apply to just that time.
The date any „text” value returns in the English language. However, there is another function, strftime, which, like the date function, is used to format the date, but is a little different behavior. First, the format elements (other than as a function of date) are not individual letters, but always are preceded by a percent sign, which can be inserted into plain text format. The second important difference is taken into account system locale locale.