SEARCH:
Previous: hpct Next: hDateWords

hDate

String/Number input_value
String Format_String (optional)
HTML
3/31/07
char,char
3/31/07,
3/9/07,d-mm-yyyy
3/9/07,dd-mm-yyyy
3/9/07,ddd-mm-yyyy
3/9/07,Ddd-mm-yyyy
3/9/07,DDD-mm-yyyy
3/9/07,dddd-mm-yyyy
3/9/07,Dddd-mm-yyyy
3/9/07,DDDD-mm-yyyy
3/9/07,m/d/yy
3/9/07,mm/d/yy
3/9/07,mmm/d/yy
3/9/07,Mmm/d/yy
3/9/07,MMM/d/yy
3/9/07,mmmm/d/yy
3/9/07,Mddd/d/yy
3/9/07,MMMM/d/yy
3/9/07,m/d/yy
3/9/07,m/d/yyyy
1/1/07 ,m-d-y EXTRA m ** d ** yyyy
12/31/07,m-d-y EXTRA mm ** ddd ** yyyy


Accepts either a string or a unix timestamp and returns a string that can be sent to the browser. This is a great function for people who cannot remember the formatting codes for the date function.

If the first parameter is a string, hDate passes it through strototime to convert it into a timestamp. If the first parameter is a number hDate assumes it is a unix timestamp.

If no second parameter is provided, hDate calls date with the string 'm/d/Y', a standard US date format.

The real value of hDate comes into play if you can never remember those strange formatting strings for date. The strings for hDate are much easier to remember. They are:

  • d: day of the month without leading zeros. date('j')
  • dd: day of the month with leading zeros. date('d')
  • ddd: short textual day of week, same as strtolower(date('D'))
  • Ddd: short textual day of week, same as date('D')
  • DDD: short textual day of week, same as strtoupper(date('D'))
  • dddd: full textual day of week, same as strtolower(date('l'))
  • Dddd: full textual day of week, same as date('l')
  • DDDD: full textual day of week, same as strtoupper(date('l'))
  • m: numeric month without leading zeros. date('n')
  • mm: numeric month with leading zeros. date('m')
  • mmm: short textual month name, same as strtolower(date('M'))
  • Mmm: short textual month name, same as date('M')
  • MMM: short textual month name, same as strtoupper(date('M'))
  • mmmm: full textual month name, same as strtolower(date('F'))
  • Mmmm: full textual month name, same as date('F')
  • MMMM: full textual month name, same as strtoupper(date('F'))
  • yy: 2-digit year. date('y')
  • yyyy: 4-digit year. date('Y')

Previous: hpct Next: hDateWords