- 0
Convert Video Duration Number to Time with PHP or jQuery
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Jaybonaut · Posted
Couple years ago I got a brand new 4TB Samsung 990 Pro for $250 during Black Friday -
-
By Jaybonaut · Posted
Can confirm, I've built stuff for others and no complaints using their products. -
By Jaybonaut · Posted
Yes I agree, it's annoying. You can now miss tabs unless you point low enough. -
By Copernic · Posted
Sysinternals Suite 2026.17.06 by Razvan Serea The Sysinternals Suite is a comprehensive package of advanced Windows utilities created by Mark Russinovich, who launched the Sysinternals website in 1996 to share his system tools and technical resources. This suite combines a wide range of troubleshooting and diagnostic tools, including Process Explorer, Process Monitor, Sysmon, Autoruns, ProcDump, the PsTools collection, and many others. It provides everything IT professionals and developers need to manage, monitor, and troubleshoot Windows systems and applications. The Suite bundles all of the core troubleshooting utilities along with their help files. Non-troubleshooting extras—such as the BSOD Screen Saver or NotMyFault—are excluded. In addition to the well-known tools, it also includes AccessChk, Autologon, Ctrl2Cap, DiskView, Disk Usage (DU), LogonSessions, PageDefrag, PsLogList, PsPasswd, RegMon, RootkitRevealer, TCPView, VMMap, ZoomIt, and more. Sysinternals Suite 2026.17.06 changelog: Autoruns v14.3 - This update to Autoruns, a utility for monitoring startup items, adds bug fixes and improves the command-line application autorunsc. ZoomIt v12.1 - This update to ZoomIt, a screen magnification and annotation tool, adds image backgrounds, webcam background blur and microphone noise cancellation support. Coreinfo v4.01 - This update to Coreinfo, a tool that reports processor, socket, NUMA memory, and cache topology of a system, as well as processor features supported, adds support for new processor features. DebugView v5.02 - This update to DebugView, a tool for displaying both kernel-mode and Win32 debug output, adds Ctrl-Shift-A support for selecting all output, and agent skills support for the CLI utility. LiveKd v5.64 - This update to LiveKd, a utility that allows running the kernel debugger on a live system, fixes a debugging privileges issue. ProcDump 3.5.2 for Linux - This update to ProcDump for Linux, a tool for capturing process dumps, adds .NET counters and a custom core dumper. Process Monitor v4.04 - This update to Process Monitor, a utility for observing real-time file system, Registry, and process or thread activity, adds some bug fixes Sysmon v15.21 - This update to Sysmon, an advanced host security monitoring tool, adds some bug fixes. Download: Sysinternals Suite 2026.17.06 | 168.0 MB (Freeware) Download: Sysinternals Suite for ARM64 | 15.4 MB Link: Sysinternals Suite Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
-
-
Recent Achievements
-
Classifyskilleducation earned a badge
Week One Done
-
eurospharma62 earned a badge
One Month Later
-
With What earned a badge
Week One Done
-
Harris Gilbert earned a badge
Week One Done
-
Vincian earned a badge
One Month Later
-
-
Popular Contributors
-
Tell a friend
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