#1
  1. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,650
    Rep Power
    171

    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?
    PHP 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
    */ 
    Thanks
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    119
    Rep Power
    32
    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
  4. #3
  5. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,965
    Rep Power
    9397
    The second argument to strtotime() has to be a Unix timestamp, not a date string.

    Comments on this post

    • ManiacDan agrees

IMN logo majestic logo threadwatch logo seochat tools logo