• Greetings,

    i have some issues with my Theme, for the moment i use this format to Display a Date of a post.

    <?php the_time(‘F j, Y’); ?>  <?php the_time(‘g:i a’); ?>

    I read the article about time conversion but don’t get it. This is above my skills.

    http://codex.wordpress.org/Function_Reference/date_i18n

    How would it be possible to display “X hours Ago” if its below 24 hours and after to display it as Date?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You’re looking for human_time_diff.

    Thread Starter Theunknown1

    (@deexgnome)

    Yes that should be it.. but it will say “1 day ago.. 2 days ago” is there a limit like

    Show alle with ago if its below 24 hours?

    Thread Starter Theunknown1

    (@deexgnome)

    Okay i found this nice little script

    <?php
    $time = get_the_time('U'); // Get the timestamp of the post for easy access.
    $diff = round((time() + (get_settings('gmt_offset') * 3600) - get_the_time('Z') - $time) / 60); // Get difference in minutes.
    $diff_in_days = round($diff / 60 / 24); // Get difference in days.
    if ($diff < 2) {
           echo 'Vor einer Minute';
    } elseif ($diff < 30) {
           echo 'Vor ' . $diff . ' Minuten';
    } elseif ($diff_in_days < 1) {
           echo 'Heute, um ' . date('H:i', $time) . ' Uhr';
    } elseif ($diff_in_days < 2) {
           echo 'Gestern, um ' . date('H:i', $time) . ' Uhr';
    } elseif ($diff_in_days < 7) {
           echo 'Am ' . get_the_time('l') . ' um ' . date('H:i', $time) . ' Uhr';
    } elseif ($diff_in_days < 365) {
           echo 'Am ' . get_the_time('l, j. F') . ' um ' . date('H:i', $time) . ' Uhr';
    } else {
           echo 'Am ' . get_the_time('l, j. F Y') . ' um ' . date('H:i', $time) . ' Uhr';
    } ?>

    I think i yust need to translate it to en-GB

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Time conversion’ is closed to new replies.