SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Change Display Time Format

    Good day!

    I have Hours field in my database and the datatype is time, I have template that displayed the data of Hours, the data in database is like this 40:00:00 , I want to display the value in my webpage like this 40.00 the 40 is hours and 00 is minutes. Is it possible?How?

    Thank you...

    Here is my code to display the Hours:
    Code:
    <input name= "Hours" class = "LField" type="text" maxlength="12" tabindex="0" size="12"  value="{$Hours}" readonly="readonly" style="background: #e2e2e2"/>
    Thank you so much

  2. #2
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    PHP Code:
    <?php
    $hours 
    '40:00:00';

    // do this in your controller before passing the $hours value to your template
    $hours substr($hours05);
    $hours str_replace(':''.'$hours);
    ?>
    If these are hours that someone has worked (for example), it might be best to store the hours as a number, and not as a time. I think the time data type is meant more for one specific point in time, e.g. 8:35 in the morning, and not really for counting hours.

  3. #3
    SitePoint Guru
    Join Date
    Oct 2011
    Posts
    658
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you it works...
    I used time because it is the sum of attendance.

    Thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •