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.
- Maximize the total profit of all the persons
- How to calculate the difference between two dates in PHP?
- How to calculate the number of words in a string using JQuery?
- PHP | time() Function
- PHP | Date and Time
- Just In Time Compiler
- HTML | <time> Tag
- Generating OTP (One time Password) in PHP
- Ruby Date and Time
- HTML | DOM Time Object
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.