Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! How do I calculate the diference between two Times?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

How do I calculate the diference between two Times? GMT

It's not simple as this:
$time1=10:00:31;
$time2=12:00:00;
$diference=$time1-$time2;

there are something i forgot:)

Could you help me? Give a try:)

 
PHP does not recognize time in the format 00:00:00, it actually sees that as a string. What you need to do it translate the times into a recognizeable format (Unix Timestamp), do the calcuations, and then translate the result into the format you want displayed.

Example:
Code:
$time1 = gmmktime(10,0,31,1,1,2000);
$time2 = gmmktime(12,0,00,1,1,2000);
$diference=$time1-$time2; //time difference in seconds

Check out
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top