Issue with php strtotime function when using ordinal values -


i sometime unexpected results when using ordinal values strtotime. example, why

date("m j", strtotime("second tuesday february 2011")) 

result in "feb 15" (which third tuesday in 2011?

you missing 'of'.

$ php -r 'echo date("m j", strtotime("second tuesday february 2011"));'
feb 15

$ php -r 'echo date("m j", strtotime("second tuesday of february 2011"));'
feb 8

php version:

$ php -v
php 5.3.3 (cli) (built: aug 22 2010 19:41:55)
copyright (c) 1997-2010 php group
zend engine v2.3.0, copyright (c) 1998-2010 zend technologies

the documentation tells cause this:

also observe "of" in "ordinal space dayname space 'of' " , "'last' space dayname space 'of' " special.

  • it sets day-of-month 1.
  • "ordinal dayname 'of' " not advance day. (example: "first tuesday of july 2008" means "2008-07-01").
  • "ordinal dayname " advance day. (example: "first tuesday july 2008" means "2008-07-08", see point 4 in list above).

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -