RE: [PHP] time to seconds
| From: | Warren Daly | Date: | Wed, 18 Sep 2002 09:25:00 +0000 |
| Subject: | RE: [PHP] time to seconds | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-116700@lists.php.net to get a copy of this message | ||
if your data is in UNIX TIMESTAMP format:
$result = mysql_query("select * from table1;",$db);
while ($row = mysql_fetch_array($result)){
// convert seconds from epoch into human date //
$data[] = date("Hi",mktime(0,0,$row['duration'],1,1,1970));
}
so I guess using mktime to convert DATE into unix timestamp
///mktime to recreate the unix timestamp
$result = mysql_query("select * from table1;",$db);
while ($row = mysql_fetch_array($result)){
$data[] = mktime($hours ,$minutes, $seconds,$month ,$day,$year);
}
to sum the row you would need to add something like this.
$result = mysql_query("select * from table1;",$db);
while ($row = mysql_fetch_array($result)){
$var = $row['duration']
$sum = $var + $sum
}
echo $sum
but I'm sure other people have much better ways of doing it:) it's a bit
early in the morning for me....
hope this helps.
Warren
-----Original Message-----
From: adi [mailto:adipublic@home.ro]
Sent: Wednesday, September 18, 2002 9:55 AM
To: PHP-General
Subject: [PHP] time to seconds
Hi, I have a table table1, with a column "Duration" time type(ex
00:12:30)
I want to make in PHP a sql selection:
SELECT * from table1 WHERE condition, and after that, to make sum of
values
of column "Duration" and display it.
Any Help?
How to transform time in seconds, with php functions?
tx
Attachment: [application/x-pkcs7-signature] smime.p7s
Attachment: [application/x-pkcs7-signature] smime.p7s