Title: Time conversion
Last modified: August 21, 2016

---

# Time conversion

 *  [Theunknown1](https://wordpress.org/support/users/deexgnome/)
 * (@deexgnome)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/time-conversion/)
 * 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](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)

 *  [tungdo](https://wordpress.org/support/users/tungdo/)
 * (@tungdo)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/time-conversion/#post-5108365)
 * You’re looking for [human_time_diff](http://codex.wordpress.org/Function_Reference/human_time_diff).
 *  Thread Starter [Theunknown1](https://wordpress.org/support/users/deexgnome/)
 * (@deexgnome)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/time-conversion/#post-5108400)
 * 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](https://wordpress.org/support/users/deexgnome/)
 * (@deexgnome)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/time-conversion/#post-5108402)
 * 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.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Theunknown1](https://wordpress.org/support/users/deexgnome/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/time-conversion/#post-5108402)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
