Jump to content

Recommended Posts

Hi guys, I'm new to this forum and hope this is the right place to post this question. I run an internet radio station using SAM Broadcaster. I am trying to display the duration of the song on my main page without the front zero (see enclosed picture): I want the duration to display like this: example (5:47) instead of with the front zero (05:47) Here is a snipet of the code I think it needs to be changed in here somewhere:

 

 

<td><?php echo preg_replace("/[^!<>@&\/\sA-Za-z0-9_]/","", $row['title']); ?><br><a href="javascript:void(0);" class="album"><strong><?php echo preg_replace("/[^!<>@&\/\sA-Za-z0-9_]/","", $row['artist']); ?></strong></a> (<?php echo date('i:s',$row['duration'] / 1000); echo $duration[0] === '0' ? substr($duration, 1) : $duration; ?>)<div class="albuminfo">
<?php if(!$row['album']) { echo "No Album Specified"; } else { ?><strong>From album:</strong> <?php echo $row['album']; ?><?php } ?></div></td>
<td align="right">
<?php if ($first) { $first = false; ?><font color="red"><strong>ON-AIR NOW</strong></font><?php } else { ?><strong><?php echo date('h:ia', strtotime($row['date_played'])); ?> EST</strong><? } ?>
<?php if(!$row['code'] == "200") {
// if there is no request
} else { ?>
<br>
Requested By: <strong><?php if(!$row['name']) { echo "An Oldies Lover"; }else{ echo $row['name']; } ?></strong><br>
<?php if(!$row['msg']) { }else{ echo '<em>"'.$row['msg'].'"</em>'; } ?>
<?php } ?>
</td>
 
 
 
Any help would be appreciated

post-168967-0-60639900-1400594041_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/288631-song-duration-display/
Share on other sites

Try changing this

 

date('h:ia', strtotime($row['date_played']))

 

To this:

 

date('g:ia', strtotime($row['date_played']))

 

 

Note that I changed the "h" to "g". More information about the date() function can be found here:

http://php.net/manual/en/function.date.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.