Set Zend_Date Month using User Input

2019-09-10 18:36发布

问题:

I'm looking for a way to set the month of Zend_Date using a string from the user (could be Jan, January, etc). For example

$month = strftime("%m", strtotime($month));
$date->set($month, Zend_Date::MONTH);

Will get the month 'number', which then can be used to set the Zend_Date month. Is there a way to do that all with Zend_Date?

回答1:

$month = 'January';  // Or 'Jan' or 1 or '1' or '01'
$date->setMonth($month);