How do I show the current date in a Wordpress post/page?

2 replies
To be clear, I'm not talking about editing the Wordpress theme script - that isn't what I mean. What I want to know is whether there's a simple way to embed a call or add some script to a blog post so that when the post/page is displayed - it shows the current date in the body text. That way, when a visitor lands on this post/page they can see a dynamic date instead of a fixed one.

Thanks in advance for any assistance or advice.
#current #date #post or page #show #wordpress
  • Profile picture of the author Harrison Ortega
    Hey James, 1st you'll need a plugin to allow php execution inside the page/post write panel. Here is one you can use WordPress › PHP Execution WordPress Plugins

    Then, after the plugin is installed and activated you can insert this PHP code anywhere you want on your write panel.

    Code:
    <?php echo date("F j, Y"); ?>
    Here are some variations that can be used:
    Code:
    l, F j, Y     output:  Monday, September 20, 2010
    m/j/y g:i A   output: 09/20/10 9:35 AM
    Y             output: 2010
    F j, Y        output: September 20, 2010 
    j F Y         output: 20 September 2010
    Harrison

    Originally Posted by jamesburchill View Post

    To be clear, I'm not talking about editing the Wordpress theme script - that isn't what I mean. What I want to know is whether there's a simple way to embed a call or add some script to a blog post so that when the post/page is displayed - it shows the current date in the body text. That way, when a visitor lands on this post/page they can see a dynamic date instead of a fixed one.

    Thanks in advance for any assistance or advice.
    Signature
    NJ web design / NJ Web Designer. MY Wordpress portfolio. 10 years of HTML/CSS - 6 years developing professional Wordpress websites. Currently not available for services.
    {{ DiscussionBoard.errors[2622421].message }}
    • Profile picture of the author mojojuju
      Using PHP will result in the page displaying an incorrect date some of the time for people who don't reside in the same time zone that is being used to generate the date on the server.

      Using Javascript to get the date from the visitor's computer might be better. Or you could get the visitors location from the IP, using a GeoIP solution, and from there find out their timezone to be used to echo the right date.

      Just wondering why you need to put the date on a web site.
      Signature

      :)

      {{ DiscussionBoard.errors[2622977].message }}

Trending Topics