Loading ...
Sorry, an error occurred while loading the content.

Re: [bang-phpug] add two times together in php

Expand Messages
  • Pradeep B V
    here you go..
    Message 1 of 2 , Jul 27, 2007
    • 0 Attachment
      here you go..

      <?php
      // the array having times.
      $ary = array("00:01:04", "00:00:48", "00:02:31", "00:00:35", "00:04:55", "00:13:42", "00:14:12");

      // lets a have a temp variable to add the times
      $tm = 0;

      // loop through the array and add the times in the array to the temp variable. strtotime converts a string to time.
      for($i=0;$i<count($ary);$i++){
      $tm = $tm + strtotime($ary[$i]);
      }

      // echo back the time in format of choice.
      echo date('H:i:s', $tm);

      //profit!
      ?>


      Pradeep B V



      ----- Original Message ----
      From: Pritesh Loke <priteshloke@...>
      To: "bang-phpug@yahoogroups.com" <bang-phpug@yahoogroups.com>; "php4india@yahoogroups.com" <php4india@yahoogroups.com>; "php_and_mysql@yahoogroups.com" <php_and_mysql@yahoogroups.com>
      Sent: Friday, 27 July, 2007 10:29:39 AM
      Subject: [bang-phpug] add two times together in php

      Hello to all

      how can i add 2 times together in php ?


      Array ( [0] => 00:01:04 [1] => 00:00:48 [2] => 00:02:31 [3] => 00:00:35 [4] => 00:04:55 [5] => 00:13:42 [6] => 00:14:12 ) Test end


      this is my time array i have to add this all and want in correct format H:i:s

      ????

      Thank you


      PML

      ---------------------------------
      Park yourself in front of a world of choices in alternative vehicles.
      Visit the Yahoo! Auto Green Center.

      [Non-text portions of this message have been removed]




      Yahoo! Groups Links










      Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.