Title: show date using epoch
Last modified: May 23, 2020

---

# show date using epoch

 *  Resolved [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/)
 * Is there a shortcode showing the date and time using epoch?

Viewing 15 replies - 1 through 15 (of 15 total)

 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12880922)
 * Hi [@pietgolf](https://wordpress.org/support/users/pietgolf/),
 * Can you please describe in details a little bit?
 * Do you need to put epoch (timestamp) somewhere and produce date and time like
   May 23, 2020 20:28? Or something else?
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12881004)
 * I am using another plugin for showing the production of our solarpanels using
   shortcodes. One of these shortcodes is for showing the last update (date and 
   time). This shortcode doesn’t actually show the date and time but the date/time
   in epoch format.
 * I do need to get the correct date/time to show to our users. I do have 2 problems:
   
   1. I don’t know how to get the value of the epoch time in a variable or something
   like that that I can use as input for another shortcode/function. The plugin 
   I am using has a shortcode to display epoch[last_update] 2. I do need a way to
   get the correct date/time based on the epoch time (timestamp)
 * It should be a great help if you can have a shortcode to show the correct date/
   time based on the epoch date/time and hopefully you can tell me how to get the
   epoch date/time as input for your shortcode.
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12881117)
 * Hi again,
 * There is no direct way to do this via our plugin, but you can put the code below
   in your functions.php in the child theme.
 *     ```
       function denra_last_update() {
           return date(get_option('date_format') . ' ' . get_option('time_format'), do_shortcode('[last_update]'));
       }
       add_shortcode('denra-last-update', 'denra_last_update');
       ```
   
 * Then you can use the [denra-last-update] to display the date and time in the 
   default readable format taken from the WordPress General Settings in the same
   way you have used the previous shortcode by now.
 * If you wish to use another format, just remove the first part in the date function(
   to the comma) and replace it with any [PHP date() function](https://www.php.net/manual/en/function.date.php)
   string that you like. Something like this:
 * `date('F j, Y H:i:s', do_shortcode('[last_update]'));`
 * Pease try it and let me know if it works.
    -  This reply was modified 5 years, 11 months ago by [Denra.com](https://wordpress.org/support/users/denra/).
    -  This reply was modified 5 years, 11 months ago by [t-p](https://wordpress.org/support/users/t-p/).
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883196)
 * Thank you for your help. It is displaying the date and time from the epoch of[
   last_update] but not the correct timezone. It is displaying the UTC date/time.
   But the good news is that I can now display the date and time using your shortcode.
 * Using another format seems not to work for me but maybe I just don’t understand
   what you mean.
 * Coudl you please change this line using the other format you mentioned?
 * return date(get_option(‘date_format’) . ‘ ‘ . get_option(‘time_format’), do_shortcode(‘[
   last_update]’));
 * It is for me a good exercise to get more familiar with php and shortcodes.
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883238)
 * Hi [@pietgolf](https://wordpress.org/support/users/pietgolf/),
 * What is the date and time format you wish to be displayed and in which timezone?
   Show me an example date and time format you would like to have r.e. October 12,
   2020 – 10:44, 2020-10-12 10:44:15, or other.
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883241)
 * PS: Do you have the correct timezone set in the General Settings of WordPress?
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883261)
 * I used also your shortcode [wpdts-date-time] on my page and this is showing 24
   mei 2020 14:44. This is the format that I want. [denra_last_update] is showing‘
   24 May 2020 12:38’ This should be ‘24 mei 14:38’. I am very gratefull that you
   take the time to help me.
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883276)
 * Do you have the correct timezone set in the General Settings of WordPress?
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883282)
 * The timezone is set to ‘Amsterdam’
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883316)
 * It seems that the other plugin is using the wrong function to get the time from
   WordPress since they must use the current_time() function to get the initial 
   timestamp with the timezone but they do not and they get the time without the
   timezone difference (you may let them know that). So you need to make a little
   hack now to get the correct timestamp until the time when/if they fix it.
 * You can use the following code:
 *     ```
       function denra_last_update() {
           $hours_diff = 2;
           return date_i18n(
                 get_option('date_format') . ' ' . get_option('time_format'), 
                 intval(do_shortcode('[last_update]')) + ($hours_diff * 3600), false);
       }
       add_shortcode('denra-last-update', 'denra_last_update');
       ```
   
 * Please let me know if it works.
    -  This reply was modified 5 years, 11 months ago by [Denra.com](https://wordpress.org/support/users/denra/).
      Reason: Error in code fixed. Added bracket
    -  This reply was modified 5 years, 11 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883403)
 * Using the code you send me
 * **function denra_last_update() {
    $hours_diff = 2; return date_i18n( get_option(‘
   date_format’) . ‘ ‘ . get_option(‘time_format’), intval(do_shortcode(‘[last_update]’)
   + ($hours_diff \* 3600), false)); } add_shortcode(‘denra-last-update’, ‘denra_last_update’);
 * On my page no date or time but text [denra_last_update]
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883444)
 * Can I send you a private message?
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883465)
 * Please email me to [support@denra.com](https://wordpress.org/support/topic/show-date-using-epoch/support@denra.com?output_format=md)
 *  Plugin Author [Denra.com](https://wordpress.org/support/users/denra/)
 * (@denra)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883911)
 * I am glad that we helped you solve your issue.
 * Please let me know if I can close this thread as solved.
 *  Thread Starter [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * (@pietgolf)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883915)
 * Problem solved. Thank you

Viewing 15 replies - 1 through 15 (of 15 total)

The topic ‘show date using epoch’ is closed to new replies.

 * ![](https://ps.w.org/wp-date-and-time-shortcode/assets/icon.svg?rev=2291661)
 * [WP Date and Time Shortcode](https://wordpress.org/plugins/wp-date-and-time-shortcode/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-date-and-time-shortcode/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-date-and-time-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-date-and-time-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-date-and-time-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-date-and-time-shortcode/reviews/)

## Tags

 * [convert](https://wordpress.org/support/topic-tag/convert/)
 * [date](https://wordpress.org/support/topic-tag/date/)
 * [display](https://wordpress.org/support/topic-tag/display/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [show](https://wordpress.org/support/topic-tag/show/)
 * [time](https://wordpress.org/support/topic-tag/time/)
 * [timestamp](https://wordpress.org/support/topic-tag/timestamp/)

 * 15 replies
 * 2 participants
 * Last reply from: [pietgolf](https://wordpress.org/support/users/pietgolf/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/show-date-using-epoch/#post-12883915)
 * Status: resolved