WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my plugin, I am trying to get the current date/time of the blog into the code but it seems to be returning a odd date/time. If i put a new post on the blog it does show the correct date/time so I am not sure what the issue is. Am I handling the code incorrectly? (Post Time: Published on: Feb 13, 2012 @ 22:45)

PHP Code

$t_time = get_the_time( __( 'Y/m/d g:i:s A' ) );
echo "<h1>BLOG TIME</h1>";
echo $t_time . "<br>";
echo "<br>";
echo "<h1>SERVER TIME</h1>";
echo date("Y/m/d g:i:s A");

OUTPUT BLOG TIME 2011/05/20 10:28:16 PM

SERVER TIME 2012/02/14 5:41:35 AM

share|improve this question
up vote 7 down vote accepted

There is a function in WordPress called current_time(); which you pass either 'timestamp' or 'mysql' to and it returns a time.

For more information: http://codex.wordpress.org/Function_Reference/current_time

share|improve this answer
+1. I would add that WordPress forces the server timezone to be UTC, which is why you should use WordPress' functions (as they take this into account) rather than native PHP ones. – Stephen Harris Feb 14 '12 at 9:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.