Hướng dẫn minutes in php
Given a series of hours, minutes, and seconds (ex: 01:30:00 or 00:30:00), I would like to add up each and convert the sum to seconds. Show For example, if the total time is 02:30:00, the total time should be in seconds. Thanks! asked May 16, 2011 at 15:19
answered May 16, 2011 at 15:22 Marc BMarc B 351k42 gold badges402 silver badges486 bronze badges 1 OK. basic multiplication:
Demo: http://codepad.org/PaXcgdNc answered May 16, 2011 at 15:22 NaftaliNaftali 143k39 gold badges240 silver badges299 bronze badges 0 Try this:
answered May 16, 2011 at 15:22 Sam MaguraSam Magura 7666 silver badges13 bronze badges Try
answered May 16, 2011 at 15:23 RobRob 1,2052 gold badges19 silver badges44 bronze badges The following is really easy way to add days, minutes, hours and seconds to a time using PHP. Using the date function to set the format of the date to be returned then using strtotime to add the increase or decrease of time then after a comma use another strtotime passing in the start date and time.
Times can be entered in a readable way:
To sub-tract time its the same except a - is used instead of a + Home » How To Guides » PHP » How to add Days, Hours, Minutes, and Seconds to Datetime in PHP Here we’ll provide the simplest way to add days, minutes, hours and seconds to time using PHP. In PHP, using
$startTime = date("Y-m-d H:i:s");//display the starting time Using the above code you can add time to current time or any desire time. To sub-track use the same code except How to add hours to time in php?In your case to increase the current time by 10 hours: $date = date('h:i:s A', strtotime('+10 hours')); How can I add minutes and minutes in 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 time add 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 can I get minutes in php?$min = $interval ->days * 24 * 60; $min += $interval ->h * 60; $min += $interval ->i; // Printing the Result in Minutes format. |