Development

formatDateHowTo (diff)

You must first sign up to be able to contribute.

Changes from Version 1 of formatDateHowTo

Show
Ignore:
Author:
basos (IP: 85.72.150.160)
Timestamp:
02/02/10 17:48:00 (8 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • formatDateHowTo

    v0 v1  
     1 
     2== Supported formats for symfony format_date helper == 
     3 (based on the sfDateFormat::format() method ) 
     4 
     5This is a date/time format helper. It is i18n aware which means that it's output is affected by the i18n setting of symfony and the current sf_user culture variable. It supports some out of the box formats but can be very flexible. The following listing is a quick reference to all the supported patterns. (It corresponds to symfony 1.2.10). 
     6 
     7'''Out of the box format patterns''' 
     8 
     9These formats correspond to '''one letter''' patterns. 
     10This is the list of out of the box patterns with example outputs for 2 locales (en, el) 
     11 
     12'''locale: en''' 
     13 
     14 * d :2010-02-02 
     15 * D :2 February 2010 
     16 * p :2 Feb 2010 
     17 * P :Tuesday 2 February 2010 
     18 * t :17:58 
     19 * T :17:58:37 UTC 
     20 * q :17:58:37 
     21 * Q :17:58:37 UTC 
     22 * f :2 February 2010 17:58 
     23 * F :2 February 2010 17:58:37 UTC 
     24 * g :2010-02-02 17:58 
     25 * G :2010-02-02 17:58:37 UTC 
     26 * i :2010-02-02 
     27 * I :2010-02-02 17:58:37 
     28 * M :February 02 
     29 * m :February 02 
     30 * R :Tue, 02 Feb 2010 17:58:37 
     31 * r :Tue, 02 Feb 2010 17:58:37 
     32 * s :2010-02-02T17:58:37 
     33 * u :2010-02-02 17:58:37 UTC 
     34 * U :Tuesday 02 February 2010 17:58:37 
     35 * Y :2010 February 
     36 * y :2010 February 
     37 
     38'''locale: el''' 
     39 
     40 * d :02/02/2010 
     41 * D :02 Φεβρουαρίου 2010 
     42 * p :02 Φεβ 2010 
     43 * P :Τρίτη, 02 Φεβρουαρίου 2010 
     44 * t :5:58 ΜΜ 
     45 * T :5:58:37 ΜΜ UTC 
     46 * q :5:58:37 ΜΜ 
     47 * Q :5:58:37 ΜΜ UTC 
     48 * f :02 Φεβρουαρίου 2010 5:58 ΜΜ 
     49 * F :02 Φεβρουαρίου 2010 5:58:37 ΜΜ UTC 
     50 * g :02/02/2010 5:58 ΜΜ 
     51 * G :02/02/2010 5:58:37 ΜΜ UTC 
     52 * i :2010-02-02 
     53 * I :2010-02-02 17:58:37 
     54 * M :Φεβρουαρίου 02 
     55 * m :Φεβρουαρίου 02 
     56 * R :Τρι, 02 Φεβ 2010 17:58:37 
     57 * r :Τρι, 02 Φεβ 2010 17:58:37 
     58 * s :2010-02-02T17:58:37 
     59 * u :2010-02-02 17:58:37 UTC 
     60 * U :Τρίτη 02 Φεβρουαρίου 2010 17:58:37 
     61 * Y :2010 Φεβρουαρίου 
     62 * y :2010 Φεβρουαρίου 
     63 
     64e.g. format_date( $date, 't') ; 
     65 
     66--------------------- 
     67'''Custom format patterns''' 
     68 
     69The previous one letter format patterns correspond to internal patterns.  
     70Instead of a single letter pattern a complete (internal) pattern  
     71compiled of the following internal tokens can be provided as input to the format_date. 
     72The supported internal tokens are: 
     73 
     74   * Gets the year. 
     75   * "yy" will return the last two digits of year. 
     76   * "yyyy" will return the full integer year. 
     77    
     78   * Gets the month. 
     79   * "M" will return integer 1 through 12 
     80   * "MM" will return the narrow month name, e.g. "J" 
     81   * "MMM" will return the abrreviated month name, e.g. "Jan" 
     82   * "MMMM" will return the month name, e.g. "January" 
     83 
     84   * Gets the day of the week. 
     85   * "E" will return integer 0 (for Sunday) through 6 (for Saturday). 
     86   * "EE" will return the narrow day of the week, e.g. "M" 
     87   * "EEE" will return the abrreviated day of the week, e.g. "Mon" 
     88   * "EEEE" will return the day of the week, e.g. "Monday" 
     89 
     90   * Gets the day of the month. 
     91   * "d" for non-padding,  
     92   * "dd" will always return 2 characters. 
     93   * "dddd" returns "EEEE" i.e. will return the day of the week, e.g. "Monday" 
     94    
     95   * "G" Gets the era. i.e. in gregorian, year > 0 is AD, else BC. 
     96 
     97   * Gets the hours in 24 hour format, i.e. [0-23].  
     98   * "H" for non-padding,  
     99   * "HH" will always return 2 characters. 
     100    
     101   * "a" Get the AM/PM designator, 12 noon is PM, 12 midnight is AM. 
     102    
     103   * Gets the hours in 12 hour format.  
     104   * "h" for non-padding,  
     105   * "hh" will always return 2 characters. 
     106    
     107   * Gets the minutes. 
     108   * "m" for non-padding,  
     109   * "mm" will always return 2 characters. 
     110    
     111   * Gets the seconds. 
     112   * "s" for non-padding, 
     113   * "ss" will always return 2 characters. 
     114    
     115   * "z" Gets the timezone from the server machine. 
     116 
     117   * "D" Gets the day in the year, e.g. [1-366] 
     118    
     119   * Gets day in the month. 
     120   * "F" for non padding 
     121   * "FF" will always return 2 chars 
     122    
     123   * "w" Gets the week in the year. 
     124    
     125   * "W" Gets week in the month. 
     126    
     127   * "k" Gets the hours [1-24]. 
     128    
     129   * "K" Gets the hours in AM/PM format, e.g [1-12] 
     130 
     131 
     132e.g. for en culture 
     133format_date( $date, 'EEE, dd MMM yyyy')  
     134Tue, 02 Feb 2010  
     135which is not in the out the box list :)