Title: wordpress affecting time() function
Last modified: August 20, 2016

---

# wordpress affecting time() function

 *  Resolved [deko](https://wordpress.org/support/users/deko/)
 * (@deko)
 * [14 years ago](https://wordpress.org/support/topic/wordpress-affecting-time-function/)
 * I have a PHP script that is called in the footer of my blog pages and also at
   the end of a few stand-alone pages. The exact same script runs, but when called
   from the blog footer, it returns a different value than it does from the stand-
   alone pages. The script uses `time()` to get a time value.
 * The output below is what I am seeing. The 9:41 time is correct and is returned
   by the script when called from the stand-alone (non-blog) pages. The 4:41 time
   is 7 hours ahead of the server’s local time (which is 9:41) and is returned when
   the script is called from the blog pages.
 * Is there some function WordPress uses that resets the time to UTC? If so, how
   do I circumvent this so my script returns the correct local time?
 * I’ve tried modifying the time zone in wp-admin > Settings > General Settings 
   but it makes NO DIFFERENCE which timezone I select. The time my script returns
   is consistently 7 hours ahead – and consistently correct when called from non-
   blog pages.
 *     ```
       May 24 2012 09:41 pm
       May 24 2012 09:41 pm
       May 24 2012 09:41 pm
       May 25 2012 04:41 am
       May 25 2012 04:41 am
       May 25 2012 04:41 am
       ```
   

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

 *  [WPyogi](https://wordpress.org/support/users/wpyogi/)
 * (@wpyogi)
 * [14 years ago](https://wordpress.org/support/topic/wordpress-affecting-time-function/#post-2769281)
 * Have you looked at the Codex info on time/date? PHP does have a bunch of built-
   in time/date functions, so it’s likely something is different in those two locations
   as to how the date is displayed…
 * [http://codex.wordpress.org/Function_Reference/get_the_time](http://codex.wordpress.org/Function_Reference/get_the_time)
 *  Thread Starter [deko](https://wordpress.org/support/users/deko/)
 * (@deko)
 * [14 years ago](https://wordpress.org/support/topic/wordpress-affecting-time-function/#post-2769288)
 * `<?php get_the_time( $d, $post ); ?>`
 * _Returns the time of the current post **for use in PHP**. It does not display
   the time._
 * [get_the_time](http://codex.wordpress.org/Function_Reference/get_the_time)
 * So do I have to unravel whatever `get_the_time` is doing? Is there some function
   I can run, before my script runs, that will reset PHP so it will return the expected
   value from `time()`?
 *  Thread Starter [deko](https://wordpress.org/support/users/deko/)
 * (@deko)
 * [14 years ago](https://wordpress.org/support/topic/wordpress-affecting-time-function/#post-2769296)
 * I revised the first lines of my script to this:
 *     ```
       date_default_timezone_set('America/Los_Angeles');
       $timestamp = time();
       ```
   
 * This fixed whatever WordPress did that made the PHP `time()` function return 
   a value different from what `time()` would get from non-wp pages.

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

The topic ‘wordpress affecting time() function’ is closed to new replies.

## Tags

 * [time](https://wordpress.org/support/topic-tag/time/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [deko](https://wordpress.org/support/users/deko/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/wordpress-affecting-time-function/#post-2769296)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
