Converting String to Time

Hi all, I have a string which I have stored in my database as the time, so for example it looks like: 1304602997. However, I want this to be displayed in the following way 3:15 - so it shows only minutes and seconds. Any help on this one would be greatly appreciated :slight_smile:

Am I correct in assuming that’s a timestamp?

If so:


date('i:s', $time)

  1. Don’t store it as a string, store it as an int

:slight_smile:

Hi there, thank you for the quick reply. I was storing the timestamp as a varchart but I have no changed this to an int but it doesn’t seem to be echoing out correctly, it seems to be display the minute and seconds of the current time, not that of the stored value. Any ideas?

be careful, time() is a function which gives the current time.

you need to be using the VARIABLE $time note the $

Hi, I’m still having a problem with this, it does’t show the current time, just that of the current time. Please see code below, really appreciate any help :slight_smile:


        $time = $user['time'];
        echo $time; //1304663840
        echo "<td>".date('i:s', $time)."</td>\
";

Hi all, ok I’ve managed to do it, it was something I was doing wrong. Thanks again for the help :slight_smile: