-1

I have a variable which is holding the output of a datepicker input tag. I want to add 24 hours to it.

As it stands, if I var_dump the variable it is:

string(10) "dd/mm/yyyy"

How would I go about adding 1 day to it?

I have tried:

$finishdate2 = date('d-m-Y',strtotime($finishdate . "+1 days"));

but I seem to get some weird dates.

Nisse Engström
  • 4,738
  • 23
  • 27
  • 42
mgrantnz
  • 375
  • 1
  • 4
  • 15
  • 1
    where is your code and what you have tried for it? – Saty May 14 '15 at 05:35
  • I have tried: `$finishdate2 = date('d-m-Y',strtotime($finishdate . "+1 days"));` but i seem to get some weird dates – mgrantnz May 14 '15 at 05:39
  • 1
    possible duplicate of [adding one day to a date](http://stackoverflow.com/questions/1394791/adding-one-day-to-a-date) – Saty May 14 '15 at 05:42

3 Answers3

1
$date="10/05/2015";
$date1=str_replace("/","-",$date);
$tomorrow=date('d/m/Y',strtotime($date1 . "+1 days"));

You can try like this

Vikas Umrao
  • 2,800
  • 1
  • 15
  • 23
0

You can try with it

$your_date_variable= str_replace('/', '-', $user_iput); 
echo date('Y-m-d', strtotime($your_date_variable. ' + 1 days'));//2015-05-14
or
echo date('Y-m-d H:i:s', strtotime($your_date_variable. ' + 1 days'));//2015-05-14 11:07:07
user3419778
  • 856
  • 3
  • 8
  • 11
0

this will help you..

<?php
$date = '2015-02-28';
$date = date('Y-m-d', strtotime($date . ' + 1 day'));
echo 'date after adding 1 day: ' . $date;
?>
Kavin Smk
  • 808
  • 11
  • 37