Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

minus time  with PHP

Posted on 2006-07-24
4
Medium Priority
?
2,128 Views
Last Modified: 2012-05-05

             robert      2006-07-10 15:12:39       NULL       2006-07-10 08:00:00       NULL
             Jhon      2006-07-10 15:12:53       NULL       2006-07-10 08:00:00       NULL
             david     2006-07-11 13:48:38       NULL       2006-07-11 08:00:00       NULL

how can i minus time   such as below

 2006-07-10 15:12:39       -       2006-07-10 08:00:00

 2006-07-10 15:12:53       -      2006-07-10 08:00:00
0
Comment
Question by:teera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 300 total points
ID: 17166542
You make timestamps out of them using strtotime. Then you do $secondsDiff = $time2 - $time1

Then you need to format it in the way you like.

-r-
0
 
LVL 40

Assisted Solution

by:Richard Quadling
Richard Quadling earned 300 total points
ID: 17166683
Watch out for certain limits on different OSs. Some don't like -ve time. So make sure you always use ...

$secondsDiff = abs($time2 - $time1);

0
 
LVL 2

Assisted Solution

by:arun80_inin
arun80_inin earned 400 total points
ID: 17167115
You can use mktime like this

diff=mktime(hr1,min1,sec1,mon1,day1,year1)-mktime(hr2,min2,sec2,mon2,day2,year2);

to convert this diference to date you can do like this date("Y-m-d H:i:s",diff);
0
 
LVL 32

Accepted Solution

by:
ldbkutty earned 400 total points
ID: 17174751
Looks like an Sql would also do the Job:

SELECT TIMEDIFF(col1, col2) AS time_diff FROM table_name
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question