?
Solved

minutes without leading 0

Posted on 2014-08-15
4
Medium Priority
?
113 Views
Last Modified: 2014-08-15
Hi

In this line of code:

(($diff->format('%d')*24) + $diff->format('%h')) . ":" . $diff->format('%i');

If result is 25 hours with 20 minutes works well and displays 25:20, but when the minutes are less than 10, like 7 results in sometime like that 25:7, how i can change the format of the minute to have a leading 0, like 25:07?
0
Comment
Question by:joyacv2
  • 2
  • 2
4 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40263559
Replace
$diff->format('%i');

with

str_pad($diff->format('%i'), 2, '0', STR_PAD_LEFT);
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40263633
Hi Gary,

Is there a way to make this result sortable in the table? Thanks!!!!
0
 
LVL 58

Expert Comment

by:Gary
ID: 40263635
Sortable in what table - this is probably a new question.
0
 
LVL 1

Author Comment

by:joyacv2
ID: 40263644
Ok,

I will accept your solution that works perfect and open a new question! Thanks!
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question