title: How to convert an input string into strtotime in laravel
body: <p>I am using jQuery calendar to input dates in the form like</p>
  
  <pre><code>&lt;div class="form-group"&gt;
       &lt;label&gt;Valid From:&lt;/label&gt;
         &lt;div class="input-group date"&gt;
         &lt;div class="input-group-addon"&gt;
         &lt;i class="fa fa-calendar"&gt;&lt;/i&gt;
  &lt;/div&gt;
  &lt;input type="text" tabindex="4" data-date-start-date="0d" class="form-
   control pull-right datepicker" name="valid_from" id="datepicker2" value="
   {{old('valid_from')}}"&gt;
   &lt;/div&gt;
   @if ($errors-&gt;has('valid_from'))
   &lt;span class="has-error" style="color: red"&gt;
   &lt;strong&gt;{{ $errors-&gt;first('valid_from') }}&lt;/strong&gt;
   &lt;/span&gt;
   @endif
   &lt;/div&gt;
  </code></pre>
  
  <p>and I am getting the value in the form of <strong>09-03-2018</strong> from form.</p>
  
  <p>Model code and I tried converting it with mutator but it didn't work to model code</p>
  
  <pre><code>use SoftDeletes;
      protected $fillable = 
  ['name','valid_from','valid_to','city_id','p_limit','is_active','type'];
      protected $dates = [
  //        'valid_from',
  //        'valid_to',
          'deleted_at'
      ];
  //    public function setDateOfBirthAttribute($dates)
  //    {
  //        $this-&gt;attributes['valid_from'] = Carbon::parse($dates);
  //        $this-&gt;attributes['valid_to'] = Carbon::parse($dates);
  //        $this-&gt;attributes['deleted_at'] = Carbon::parse($dates);
  //    }
  //    protected function getDateFormat()
  //    {
  //        return 'U';
  //    }
  //    protected function getDateFormat()
  //    {
  //        return 'd-m-Y ';
  //    }
  //    public function setFirstNameAttribute($dates)
  //    {
  //        $this-&gt;attributes['valid_from'] = strtotime($dates);
  //        $this-&gt;attributes['valid_to'] = strtotime($dates);
  //        $this-&gt;attributes['deleted_at'] = strtotime($dates);
  //    }
  //    public function getValidTillValueAttribute($date)
  //    {
  //        return Carbon::now()-&gt;toRfc2822String($date);
  //    }
  //    public function setValidTillValueAttribute($value)
  //    {
  ////        $this-&gt;attributes['valid_to'] = 
   Carbon::createFromTimestamp($value);
  //        $this-&gt;attributes['valid_to'] = strtotime($value);
  //        dd($value);
  //    }
  //    public function setValidFromValueAttribute($value)
  //    {
  //        dd($value);
  ////        $this-&gt;attributes['valid_from'] = 
   Carbon::createFromTimestamp($value);
  //        $this-&gt;attributes['valid_from'] = strtotime($value);
  //    }
  </code></pre>
  
  <p>Controller code</p>
  
  <pre><code>public function store(PromotionRequest $request)
      {
          $input = $request-&gt;all();
  //        return $request-&gt;all();
          $date = $request-&gt;valid_from;
          $date1 = $request-&gt;valid_to;
          $_newDate = strtotime($date);
          $_newDate1 = strtotime($date1);
  //        dd($_newDate);
  //        dd($_newDate1);
  //        return $input;
  //        return $_newDate1;
  //        return $_newDate;
  
  //        dd($request-&gt;all());
  //        return $request-&gt;$_newDate;
  //        return $request-&gt;$_newDate1;
          Promotion::create($input,$_newDate,$_newDate1);
  //        Promotion::create($input);
  //        return redirect('admin/promotion');
      } 
  </code></pre>
  
  <p>migration code</p>
  
  <pre><code>$table-&gt;increments('id');
  $table-&gt;string('name')-&gt;unique();
  $table-&gt;integer('valid_from');
  $table-&gt;integer('valid_to');
  $table-&gt;tinyInteger('is_active')-&gt;comment('0 = Not Active, 1 = Active');
  $table-&gt;tinyInteger('type')-&gt;comment('1 = percentage, 2 = in currency');
  $table-&gt;integer('city_id')-&gt;default(1)-&gt;comment = "foreign key to cities 
  table";
  $table-&gt;integer('p_limit')-&gt;unsigined();
  $table-&gt;integer('updated_at')-&gt;unsigined();
  $table-&gt;integer('created_at')-&gt;unsigined();
  $table-&gt;integer('deleted_at')-&gt;unsigined()-&gt;nullable(true);
  $table-&gt;foreign('city_id')-&gt;refrences('id')-&gt;on('cities');
  </code></pre>
  
  <p>I want to convert it into unix_timestamp any help would be really appreciated</p>