suppose in $time1 and $time2 there is a value of mysql time type and now i want to find out the sum of those two time values and store the sum into a $tot_time how can we do that..
i have done it like below
$tot_time = 0;
$tot_time = $time1 + $time2.
but the above code is not working... how to do that then???? please help me..... thanx in advance.....
how to add two date values which are retrieved from mysql?
Moderator: General Moderators
-
vidyabhushan
- Forum Newbie
- Posts: 16
- Joined: Mon Oct 20, 2008 4:58 pm
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: how to add two date values which are retrieved from mysql?
Take a look at
Something like this should help:
Code: Select all
strtotime()Code: Select all
$xTime=strtotime("+$time1 minutes", $time2);-
vidyabhushan
- Forum Newbie
- Posts: 16
- Joined: Mon Oct 20, 2008 4:58 pm
Re: how to add two date values which are retrieved from mysql?
now i did it like this...
still its not working...
Code: Select all
$time1 = '0:20:0';
$time2 = '0:40:0';
$tot_time=strtotime("+$time1 minutes", $time2);
print $tot_time
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Re: how to add two date values which are retrieved from mysql?
I was giving that code as an illustration, look up strtotime() in the PHP manual - you'll learn more if you reseach it.
Re: how to add two date values which are retrieved from mysql?
Hi,
or split the time into it parts (explode) and uses mktime().
or split the time into it parts (explode) and uses mktime().
Re: how to add two date values which are retrieved from mysql?
What about performing it directly in the DB query?vidyabhushan wrote:suppose in $time1 and $time2 there is a value of mysql time type and now i want to find out the sum of those two time values and store the sum into a $tot_time how can we do that..
i have done it like below
$tot_time = 0;
$tot_time = $time1 + $time2.
but the above code is not working... how to do that then???? please help me..... thanx in advance.....
There are 10 types of people in this world, those who understand binary and those who don't
-
vidyabhushan
- Forum Newbie
- Posts: 16
- Joined: Mon Oct 20, 2008 4:58 pm
Re: how to add two date values which are retrieved from mysql?
Thank you all... I did it using explode() funtion...Thank you all again...