wrong php date()?
Question
hey guys,
it's weird and I've never experienced that before. I've created a new blog and a custom theme. I'm using <?php echo date("H:i"); ?>
in my theme.
The time that's put is 2h earlier. e.g. if it's actually 16:00 o'clock the date generated with date() is 14:00.
I don't know why that happens? I'm using the german wordpress version with the german language pack.
Also doesn't make a difference when putting
setlocale(LC_ALL, 'de_DE');
date_default_timezone_set('Europe/Berlin');
into wp-config.php.
any idea how I could solve that? the time set in my wordpress settings is UTC+2 which is the correct time.
Solution
This could probably make exquisite debugging session, but taking in account it's Friday evening - just use date_i18n()
instead and let WordPress deal with a huge mess that time/date issues usually are.
OTHER TIPS
Doesn't the PHP date()
function merely return a value based on the server timestamp? So, what is the current time for your server, compared to your local time? Does that account for the two-hour difference?
Try
echo date('H:i', current_time('timestamp'));
and enjoy!
I think that the problem is that the server date is different between your.
Your server has a different date
between your probably because it's placed in another state.