Welcome Guest, Not a member yet? Register   Sign In
strtotime issue
#1

[eluser]behnampmdg3[/eluser]
I use this style all over the site, but I cant find out whats wrong here? What am I doing wrong? Thanks.
Code:
$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));
//Prints 1970-02-01
/*A PHP Error was encountered
Severity: Notice
Message: A non well formed numeric value encountered
Filename: controllers/gallery.php
Line Number: 24
#2

[eluser]InsiteFX[/eluser]
I think it's because the month is missing the leading 0 (zero).
#3

[eluser]Aken[/eluser]
strtotime()'s second parameter should be a unix timestamp, not a string. http://us1.php.net/manual/en/function.strtotime.php
#4

[eluser]wilron8[/eluser]
Try this code:

Code:
$this->start_date = $this->input->post('year')."-".$this->input->post('month').'-01';
echo $this->start_date; //Prints 2014-2-01
echo'<br />';
echo $this->end_date = date('Y-m-d',strtotime('+1 month', strtotime($this->start_date)));


Since '$this->start_date' is string, you should convert it using strtotime.




Theme © iAndrew 2016 - Forum software by © MyBB