according to php.net date('m') should should 01 but i'm getting 1 instead
dirloc = date('Y') . "/" . date('m') . "/" . $word_id . "/";
according to php.net date('m') should should 01 but i'm getting 1 instead
dirloc = date('Y') . "/" . date('m') . "/" . $word_id . "/";
Install PHPUnit. Run the following UnitTest:
// make sure PHPUnit is included
class DateTest extends PHPUnit_Framework_TestCase
{
public function setup()
{
date_default_timezone_set('UTC');
}
public function getDates()
{
return array(
array('01', 'Jan'),
array('02', 'Feb'),
array('03', 'Mar'),
array('04', 'Apr'),
array('05', 'May'),
array('06', 'Jun'),
array('07', 'Jul'),
array('08', 'Aug'),
array('09', 'Sep')
);
}
/**
* @dataProvider getDates
*/
public function testDateReturnsMonthWithLeadingZero($expected, $month)
{
$this->assertSame($expected, date('m', strtotime($month)));
}
}
If the test fails with any of the given test dates, collect your PHP version and Operating system and file a bug with the PHP bugtracker. If the test passes with all the test dates, you are doing something else wrong.