Convert Seconds to hh:mm:ss from SQL

Hi, I hope someone can assist.
How can I convert an column containing seconds (integer) to display as hh:mm:ss. Since I use sqlite in this project I would normally use something like SELECT time(duration,‘unixepoch’) from table, but this does not work in SC.

Hello Cacti,

Do it yourselft using PHP function, I will assume that duration is an unix timestamp value.

  1. Create the select statement including the column in question, for example:
select duration from table
  1. Go to onRecord() event and use the following code:
{duration} = date('h:i:s', {duration});

You can see the date format in the date() manual.

Great thanks manfred.

I did not know how to reference the database value in SC. Suppose I should read the manual :wink:
Since duration is in seconds I changed the code to:

{duration} = date('H:i:s', mktime(0, 0, {duration}));

Good catch!:wink: