Given an array containing the time in hr:min:sec format. The task is to calculate the total time. If the total time is greater then 24 hours then the total time will not start with 0. It will display the total time. There are two ways to calculate the total time from the array.
- Using strtotime() function
- Using explode() function
Using strtotime() function: The strtotime() function is used to convert string into the time format. This functions returns the time in h:m:s format.
strtotime( string )
Example 1: This example reads the values from the array and converts it into the time format.
Using explode() function: The explode() function is used to break a string into an array.
array explode( separator, string, limit )
Example 2: This example reads the values from an array and converts it into the time format.
- Difference between Seek Time and Transfer Time in Disk Scheduling
- Difference between Arrival Time and Burst Time in CPU Scheduling
- Difference between Turn Around Time (TAT) and Waiting Time (WT) in CPU Scheduling
- Difference between Transfer Time and Disk Access Time in Disk Scheduling
- Difference between Seek Time and Disk Access Time in Disk Scheduling
- How to calculate P Value?
- Maximize the total profit of all the persons
- How to calculate the difference between two dates in PHP?
- How to calculate percent minus px in SASS ?
- How to Calculate the Average using Arrays in Golang?
- How to calculate the number of words in a string using JQuery?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.