January 28th, 2013, 01:05 AM
Date conversion issue with strtotime!
I use this style all over the site, but I cant find out whats wrong here?What am I doing wrong?
$this->start_date = $this->input->post('year')."-".$this->input->post('month').'-01';
echo $this->start_date; //Prints 2014-2-01
echo $this->end_date = date('Y-m-d',strtotime('+1 month', $this->start_date));
/*A PHP Error was encountered
Message: A non well formed numeric value encountered
Line Number: 24
January 28th, 2013, 02:10 AM
You are missing the leading zero on the month, it should output 2014-02-01 (not 2014-2-01 as you have) to be used as a valid date format
January 28th, 2013, 02:20 AM
The second argument to strtotime() has to be a Unix timestamp, not a date string.
Comments on this post