Php add 30 minutes to datetime
So what I need to do is add 30 minutes to the following Show
I tried this
however it does not seem to like it. I wondering what the correct why to do this is. asked Mar 22, 2012 at 22:47
RussellHarrowerRussellHarrower 6,39121 gold badges94 silver badges188 bronze badges 1 Your method of using
Output
However your method of adding time probably isn't correct. The above will work to add 30 minutes to the current time. Suppose you want to add 30 minutes from a given time,
http://codepad.org/Z5yquF55
answered Mar 22, 2012 at 22:56
I tested this code but it doesn't work for me:
Here's my solution
answered Mar 23, 2012 at 5:38
SuperNoobSuperNoob 3723 silver badges6 bronze badges
If you have answered Mar 22, 2012 at 22:57
staticsanstaticsan 29.4k4 gold badges58 silver badges73 bronze badges Try something like.
answered Mar 22, 2012 at 22:51
AdamAdam 3,5336 gold badges30 silver badges50 bronze badges Use this function:
Somnath Muluk 52.5k34 gold badges216 silver badges224 bronze badges answered Mar 22, 2012 at 22:57
sikandersikander 2,31316 silver badges23 bronze badges Not sure what your entire code looks like, but:
is returning a string. So it doesn't make sense to add the result of
(which is an integer) to that string. You either want
by itself, or
to get the formatted string. answered Mar 22, 2012 at 22:56
mattmatt 1,9281 gold badge20 silver badges28 bronze badges 1 Do you mean answered Mar 22, 2012 at 22:57
mvdnesmvdnes 3831 silver badge5 bronze badges
answered Mar 22, 2012 at 23:05
How to add minutes in DateTime using php?For this, you can use the strtotime() method. $anyVariableName= strtotime('anyDateValue + X minute'); You can put the integer value in place of X.
How to add time in time in php?PHP | DateTime add() Function
The DateTime::add() function is an inbuilt function in PHP which is used to add an amount of time (days, months, years, hours, minutes and seconds) to the given DateTime object.
How to add minutes and seconds in php?php $time = "01:30:00"; list ($hr, $min, $sec) = explode(':',$time); $time = 0; $time = (((int)$hr) * 60 * 60) + (((int)$min) * 60) + ((int)$sec); echo $time; ?>
What is the use of Strtotime function in php?The strtotime() function is a built-in function in PHP which is used to convert an English textual date-time description to a UNIX timestamp. The function accepts a string parameter in English which represents the description of date-time. For e.g., “now” refers to the current date in English date-time description.
|