I'm loading the YouTube API by jQuery + JSON to get the video info of it's views and duration.
The duration number for example is 210 sample, but in actually time, it's 3:30. :)
The problem is, I'm not sure how to come by to converting the numbers to actually time, not even with PHP's strtotime since I believe jQuery would load too late for that. (Or I don't know at all.) :p
$100 per TB is disgusting especially when we have advanced so much in this area, it's because RAM, Flash memory costs so much that creating a small factor, lots of space drives are just through the roof in material requirements.
I use it by choice but only for specific tasks that I have forgotten and it's quicker to ask then spend time wasted finding a decent answer on Google or coding a certain language. I prefer to use it.
I do think that as it gets integrated into everything, when we eventually fully rely on it, I'm talking new gens not older gens like me, that we won't think for ourselves, I mean we will become lazy thinkers, lazy logical answer to problem which will go badly.
But if we don't become fully dependant, we might be OK but I don't think personally we are going to be OK, not for the newer generations. Unless they advance in that space to the next level of intelligence where it can work out its own problems and create ideas for itself.
Question
Mr.XXIV
I'm loading the YouTube API by jQuery + JSON to get the video info of it's views and duration.
The duration number for example is 210 sample, but in actually time, it's 3:30. :)
The problem is, I'm not sure how to come by to converting the numbers to actually time, not even with PHP's strtotime since I believe jQuery would load too late for that. (Or I don't know at all.) :p
<div id="sidebar"> <h3>Related Videos</h3> <ul id="related-videos"> <?php $the_query = new WP_Query( array( 'posts_per_page' => '5', 'post_format' => 'post-format-video','category_name' => 'hip-hop') ); while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <li> <a href="<?php the_permalink();?>"> <div class="side-thumb"><?php the_post_thumbnail('small'); ?></div> <?php the_title(); ?><br /> <script type="text/javascript"> $(document).ready(function () { $.getJSON('http://gdata.youtube.com/feeds/api/videos/<?php echo getYouTubeIdFromURL(get_post_meta($post->ID,'video',true)); ?> ?v=2&alt=jsonc',function(data,status,xhr){ $("#yt_time-<?php echo get_the_ID(); ?>").html(data.data.duration); $("#yt_views-<?php echo get_the_ID(); ?>").html(data.data.viewCount); }); }); </script> <span><div class="yt">Duration: </div><div id="yt_time-<?php echo get_the_ID(); ?>" class="yt"></div><div class="yt"> | </div><div class="yt">Views: </div><div id="yt_views-<?php echo get_the_ID(); ?>"class="yt"></div></span> </a> </li> <?php endwhile;wp_reset_postdata();?> </ul><!-- #related-videos --> </div><!-- #sidebar -->I think this is the solution, but I don't exactly know how to use it. This code is from Stack Overflow.
<?php date('Y-m-d H:i:s', strtotime(sprintf('- %d second', round($speed * 60)))); ?>Here's a screenshot of what I'm working on. Check out the "Related Videos" on the bottom right.
Link to comment
https://www.neowin.net/forum/topic/1111301-convert-video-duration-number-to-time-with-php-or-jquery/Share on other sites
19 answers to this question
Recommended Posts