This topic is locked
[SOLVED]

 how Make time periods readable?

6/25/2010 8:54:17 AM
PHPRunner General questions
B
bobsansei author

Hello
Could someone help me?
how Make time periods readable? do I have to show something like 19 hours, 22 minutes, 16 seconds or 19:22:16 (i tryed view was time but this dont work <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=14702&image=1&table=forumtopics' class='bbc_emoticon' alt=':P' />)
I'm using mssql2008 and did:
select timediff (minute, camp1, camap1) as tempogasto

A
ann 6/25/2010

Rodrigo,
proceed to the View as settings on the Visual Editor tab.

Here is a sample:

$value=date('h:i:s A',strtotime($value));
B
bobsansei author 6/25/2010



Rodrigo,
proceed to the View as settings on the Visual Editor tab.

Here is a sample:

$value=date('h:i:s A',strtotime($value));



this dont return a time period this return someting like 9:23:00 Pm
i need the full time: 1h 10m 10s or 1:10:10 or in minutes 70:10 (this for a report this is sum of time)

Sergey Kornilov admin 6/25/2010

Check what other date and time formats available there:

http://www.php.net/manual/en/datetime.formats.time.php

B
bobsansei author 6/25/2010



Rodrigo,
proceed to the View as settings on the Visual Editor tab.

Here is a sample:

$value=date('h:i:s A',strtotime($value));



not found any format to solve my problem ... (The closest was $ value = date ('i: s, $ value)); But this drop in 60h
so I decided make a query this is working but sux for sun <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=50777&image=1&table=forumreplies' class='bbc_emoticon' alt=':P' /> i think cause this convert for date and i want time, well realy sorry for my crap english and if anyone knows a better solution (maybe a function?) I would be happy to know..
the query :
(convert(nvarchar, (DATEDIFF(minute, DataHoraAberto, DataHoraFechado)/60)) + ':' +

case

when (((DATEDIFF(minute, DataHoraAberto, DataHoraFechado) - ((DATEDIFF(minute, DataHoraAberto, DataHoraFechado)/60)60)))) < 10 then

'0' + convert(nvarchar, (((DATEDIFF(minute, DataHoraAberto, DataHoraFechado) - ((DATEDIFF(minute, DataHoraAberto, DataHoraFechado)/60)
60)))))

else

convert(nvarchar, (((DATEDIFF(minute, DataHoraAberto, DataHoraFechado) - ((DATEDIFF(minute, DataHoraAberto, DataHoraFechado)/60)*60)))))

end

) AS TempoGasto,

J
joker 6/25/2010

Rodrigo,
Have you seen these two functions:

<?php

function time_to_sec($time) {

$hours = substr($time, 0, -6);

$minutes = substr($time, -5, 2);

$seconds = substr($time, -2);
return $hours * 3600 + $minutes * 60 + $seconds;

}
function sec_to_time($seconds) {

$hours = floor($seconds / 3600);

$minutes = floor($seconds % 3600 / 60);

$seconds = $seconds % 60;
return sprintf("%d:%02d:%02d", $hours, $minutes, $seconds);

}

?>


I found that at the bottom of this page:

http://php.net/manual/en/book.datetime.php