![]() |
|
#1
|
|||
|
|||
Time Calculation not considering minutesHey guys,
I'm having a little trouble with time manipulation using PHP, was wondering if anybody could help me. I'm trying to input 2 time strings, and then find their difference. eg $start==09:00, $finish==10:30, and get $difference==01:30 My problem is that currently I am able to subtracts hours, but the minutes are not being considered. So the result i get from the above is 01:00 not 01:30. If i had inputted start=9:00, finish=10:59, i'd still get difference=1:00. Here is my code so far: PHP Code:
Any suggestions would be most appreciated - Justin Last edited by JdS : 31-May-2005 at 03:55.
Reason: please insert your example PHP codes between [php] and [/php] bbcode tags
|
|
#2
|
||||
|
||||
calculating time/date differenceI understand your question and I immediately searched Google because I was almost certain someone would have such a (useful) PHP function written already.
Quickly going through the links off the first 2 (SERPS) pages off a Google Search for "get time difference +php", yielded nothing like what I was expecting! I am in the mood so I think I will write a little custom function to do this easily. I will reply here when I am done... __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#3
|
||||
|
||||
|
OK, here's the function I just wrote: Get the date / time difference with PHP. I will appreciate any feedback you can share.
If you need me to explain anything, do not hesitate to ask. __________________
J de Silva Learning Journal | GIDForums™ | GIDNetwork™ | GIDWebhosts™ | GIDSearch™ |
|
#4
|
|||
|
|||
Re: Time (difference) Calculation not considering minutesHI,
Thanks for the coding. Its great. I have a problem in this. I Have a column named timeinterval which is a datetime field. I need to display every record which is greater than 30 seconds. say i have a record 2006-10-31 11:50:01. I will display this record first as i have ordered by timeinterval and asc. I will take the second record(2006-10-31 11:50:31) compare it with this one. If it is greater than 30 seconds i will display this record else proceed with the next record. How to achieve this. I tried using datediff and timediff. But both doesnt serve the purpose. I just incorporated ur code but it says error. Ending date/time is earlier than the start date/time. Will ur function solve my problem. If so how to handle it. Iam getting error. The end date is greater than the start date. Thanks jankiraman |
|
#5
|
|||
|
|||
Re: Time Calculation not considering minutesHey Guys,
Here is a solution for it ....just use it and enjoy PHP Code:
Jagpreet Globtier Infotech Quote:
Last edited by admin II : 05-Dec-2007 at 08:44.
Reason: Please surround your PHP code with [php] your code [/php]
|
Recent GIDBlog
Flickr uploads of IA pictures by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Simulation Problem | wu_weidong | C++ Forum | 7 | 12-Mar-2005 22:56 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 15:13 |
| Re: Programming Techniques | WaltP | C Programming Language | 0 | 09-Mar-2004 23:56 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The