WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Building log hour counter.. (14 posts)

  1. Rustersen
    Member
    Posted 5 years ago #

    Hey everyone.

    I am running building log over a large project, and would love to be able to show the elapsed working hours.
    I guess it should be a plugin that adds another field to the post entries, which then could be calculated to show total hours.

    Does anybody know if there is already a plugin out there that does this?

    Thanks in advance,
    Steffen.
    http://www.rv-7.dk

  2. macsoft3
    Member
    Posted 5 years ago #

    'comment_date' or 'comment_date_gmt' field under 'wp_comments' table

  3. Rustersen
    Member
    Posted 5 years ago #

    Hmm, sorry I dont have much coding experience, how can these fields help me?

  4. macsoft3
    Member
    Posted 5 years ago #

    1. Convert the current time and the comment time into time stamps.
    2. Calculate the difference.
    3. Convert the difference back into time.

  5. macsoft3
    Member
    Posted 5 years ago #

    Never mind. I've made a simple plugin. I'll release it within 24 hours.

  6. macsoft3
    Member
    Posted 5 years ago #

    Ask Google about 'WordPress Plugin: WP Relative Post Time 1.0.'

  7. Rustersen
    Member
    Posted 5 years ago #

    Hi macsoft,

    Thanks you for trying to help, but maybe I expressed my needs badly. I am not trying to calculate how much time I spend on writing the blog, but how much time I spend on building the plane I write about on my blog. If you look at my blog, you can see that I add the spent hours at the end of each post title.
    My thoughts were, if I could write these numbers in a post field somehow, a script could calculate the total hours spent and display it on my website menu.

    best regards,
    Steffen

  8. macsoft3
    Member
    Posted 5 years ago #

    Ahh... You mean, 3½h, 5h like that?

    You definitely need to create a custom field or a separate table. There can be no common WP plug-in for that for sure.

  9. macsoft3
    Member
    Posted 5 years ago #

    It won't be very difficult to achieve the goal, depending on where and how to display the total hours. Since it cannot be difficult, it will be better if you learn how to write basic PHP programs for yourself.

  10. Rustersen
    Member
    Posted 5 years ago #

    Ok, I will set aside a weekend for it! :)
    Thank you for your replies...

    Steffen.

  11. Rustersen
    Member
    Posted 5 years ago #

    Ok, I have added a custom field to my post, called it 'Hours'

    When I do this lookup in phpmyadmin it displays the total hours:

    select SUM(meta_value) from wp_postmeta WHERE meta_key='Hours'

    But what is the code to add this to my website sidebar?

  12. macsoft3
    Member
    Posted 5 years ago #

    You need a blueprint at first as to 'where and how to display the total hours.' Learning how to use phpMyAdmin to make queries won't lead you anywhere. You need to know how to make SQL queries with PHP.

  13. Rustersen
    Member
    Posted 5 years ago #

    Exactly! ..and I'm having trouble with that, so I was hoping for help through this forum.

    The phphMyAdmin can show the querie in php-code, but that doesn't help me much eather:

    $sql = 'select SUM(meta_value) from wp_postmeta WHERE meta_key=\'Hours\''

  14. Rustersen
    Member
    Posted 5 years ago #

    Ok, just got the code I was looking for from another forum:

    // Make a mysql Connection
    $query = mysql_query("SELECT sum(meta_value) AS 'meta_sum' FROM wp_postmeta WHERE meta_key='Hours'") OR DIE(mysql_error());

    while($row = mysql_fetch_assoc($query))
    {
    echo $row['meta_sum'];
    }

Topic Closed

This topic has been closed to new replies.

About this Topic