Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php date() function displaying wrong time

I'm building a site with wordpress, and when I use the date() function on an otherwise empty file, it shows the right date. However, if I use it in a file that includes other wordpress files, the time is displayed as GMT time, so the date is off.

If anyone can figure out how I can use date function without interruption from the wordpress methods, I'd appreciated it.

like image 357
ladaghini Avatar asked Apr 14 '26 01:04

ladaghini


1 Answers

I Dont use word press so im not sure but it sounds like there is a setting in wp that is applied using date_default_timezone_set(). Its probably configured to GMT to allow for easy calculation of user preferences from within WP. I would look to see if this is configurable in WP, or do the math youself using the necessary functions and/or objects.

like image 97
prodigitalson Avatar answered Apr 16 '26 13:04

prodigitalson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!