Php date () function displaying wrong time
I am building a site with wordpress and when I use the date () function on an otherwise empty file it shows the correct date. However, if I use it in a file that contains other Wordpress files, the time is displayed as GMT, so the date is off.
If anyone can figure out how I can use the date function without interrupting from wordpress methods, I would appreciate it.
a source to share
I am not using the word press, so I am not sure, but it looks like there is a parameter in wp that is applied with date_default_timezone_set()
. It is probably set to GMT to make it easier to compute custom settings from WP. I would see if this can be customized in WP or do the math with the required functions and / or objects.
a source to share
The Wordpress template tag is the_time
rendered according to your Wordpress defaults: Template tags / time "WordPress Codex . Date () can overwrite what Wordpress has written. But you can look at the the_time
usage and code examples to change the output more to what you need: Formatting date and time "WordPress Codex
a source to share
Try using the date_i18n () function available in Wordpress, I had a similar problem and I used this function, not date (). Check out WP docs - http://codex.wordpress.org/Function_Reference/date_i18n
a source to share